Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/01/2006, 10:26
crucifijo
 
Fecha de Ingreso: septiembre-2003
Mensajes: 182
Antigüedad: 21 años, 8 meses
Puntos: 1
Hacer otra busqueda conectandome a mi base de datos via codigo

Hola amigos otra vez molestando la pregunta es ¿quiero hacer una busqueda y ke me la despligue?.

Osea que tengo un boton de buscar y dos cajas de textos una cja de texto es para el nombre y la otra es para la clave y que al poner el nombre o la clave dependiendo en la caja de texto, y que al momento de darle click en el boton de buscar me lo despligue en una cuadricula.

Les dejo mi codigo para ver si alguien me puede ayudar y si conoce otra forma mas sencilla me oriente ya que estoy un poco perdido.

Private Sub Form_Load()
On Error GoTo control
grilla.TextMatrix(0, 0) = "IdProfesor"
grilla.TextMatrix(0, 1) = "Nombre"
grilla.TextMatrix(0, 2) = "Apellido"
grilla.TextMatrix(0, 3) = "Direccion"
grilla.TextMatrix(0, 4) = "Telefono"
grilla.TextMatrix(0, 5) = "Cp"
grilla.TextMatrix(0, 6) = "Rfc"
grilla.TextMatrix(0, 7) = "Curp"
grilla.TextMatrix(0, 8) = "GradoAcademico"
grilla.AddItem ""
grilla.ColWidth(0) = 700
grilla.ColWidth(1) = 2000
grilla.ColWidth(2) = 4000
grilla.ColWidth(3) = 2000
grilla.ColWidth(4) = 900
grilla.ColWidth(5) = 900
grilla.ColWidth(6) = 2000
grilla.ColWidth(7) = 2000
grilla.ColWidth(8) = 2000

' conwxion a mi base de datos
Set db = OpenDatabase(App.Path & "\bodega.mdb")
sql = "select * from profesores "
Set rs = db.OpenRecordset(sql, 2)
If rs.RecordCount > 0 Then
While Not rs.EOF
grilla.TextMatrix(grilla.Row, 0) = rs!IdProfesor
grilla.TextMatrix(grilla.Row, 1) = rs!Nombre
grilla.TextMatrix(grilla.Row, 2) = rs!Apellido
grilla.TextMatrix(grilla.Row, 3) = rs!Direccion
grilla.TextMatrix(grilla.Row, 4) = rs!Telefono
grilla.TextMatrix(grilla.Row, 5) = rs!Cp
grilla.TextMatrix(grilla.Row, 6) = rs!Rfc
grilla.TextMatrix(grilla.Row, 7) = rs!Curp
grilla.TextMatrix(grilla.Row, 8) = rs!GradoAcademico
grilla.Row = grilla.Row + 1
rs.MoveNext
Wend
grilla.Rows = grilla.Rows - 1
End If
control:
If Err.Number > 0 Then
Resume Next
End If
End Sub

Private Sub Salir_Click()
End
End Sub


Mi base de datos se llama bodega.db y la tabla de profesores se compone de la sig manera:


Profesores
IdProfesor
Nombre
Apellido
DireccionTelefono
Cp
Rfc