Visual Basic - COMO LOCALIZO UN REGISTRO

Life is soft - evento anual de software empresarial
 
Vista:

COMO LOCALIZO UN REGISTRO

Publicado por hilario (100 intervenciones) el 29/10/2004 17:56:50
MI PREGUNTA ES LA SIGUIENTE:
COMO PUEDO LOCALIZAR UN REGISTRO ESPEFICO DENTRO DE UNA TABLA, SIN UTILIZAR EL CONTROL DATA Y SIN TENER QUE BUSCAR TODOS LOS REGISTRO E IR COMPARANDO.
ES DECIR COMO USO Findfirst SIN EL CONTROL DATA.
GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:COMO LOCALIZO UN REGISTRO

Publicado por miguel (1042 intervenciones) el 29/10/2004 21:08:38
Necesitarías declarar una variable Recordset donde le asignes la base de datos y la Tabla para hacer la consulta ya que no podría poner solamente esto:
Private Sub cmdBuscar_Click()
Dim Rs As Recordset
Dim Criterio As String
Rs.FindFirst "Clave = 50"
If Rs.NoMatch Then
MsgBox "Registro No Encontrado", vbInformation
End If
End Sub
Marcaría error por lo tanto es necesario que hagas lo siguiente:
Dim WSSIG As Workspace
Dim BDMAT As Database
Private Sub cmdBuscar_Click()
Dim Rs As Recordset
Dim Sql As String
Sql = "Select Clave From CatAreas"
Set Rs = BDMAT.OpenRecordset(Sql) 'Asignamos la Tabla para hacer la busqueda
Rs.FindFirst "Clave = 1" 'Condicion de Busqueda
If Rs.NoMatch Then
MsgBox "Registro No Encontrado", vbInformation
Else
MsgBox "Registro Encontrado", vbInformation
End If
End Sub
Private Sub Form_Load()
Set WSSIG = DBEngine.Workspaces(0)
Set BDMAT = WSSIG.OpenDatabase(App.Path & "\BaseDatos.mdb")
End Sub
Pero no tendria caso poner el finfirts ya que al hacer la consulta me regreso si encontro el valor quedaría:
Private Sub cmdBuscar_Click()
Dim Rs As Recordset
Dim Sql As String
Sql = "Select Clave From CatAreas Where Clave=1"
Set Rs = BDMAT.OpenRecordset(Sql)
If Rs.RecordCount > 0 Then
MsgBox "Registro Encontrado", vbInformation
Else
MsgBox "Registro No Encontrado", vbInformation
End If
End Sub
Espero y te sirva saludos!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar