• Domingo 28 de Abril de 2024, 21:12

Autor Tema:  Buscar En Una Base De Datos  (Leído 1501 veces)

agri13

  • Nuevo Miembro
  • *
  • Mensajes: 9
    • Ver Perfil
Buscar En Una Base De Datos
« en: Miércoles 18 de Julio de 2007, 21:02 »
0
Buenas tardes!!

Mi cuestión es:
 
Tengo una base de datos en la cual se reflejan laas vacas de una granja, identificadas por un número diferente cada una.
Todos los referentes a cada vaca se insertan en la hoja mediante unos textbox y después se dan de alta con un botón de comando que me las coloca en orden ascendente según su nº.
 
Lo que querría hacer es programar unos botones para poder buscar los datos de una vaca, de manera que en textbox1 introduzco el nº de identificación de la vaca (que se ve en la columna "B") y presionando el botón "buscar" se vean todos los demás parámetros en su correspondiente textbox.
Una vez que salgan los datos en los textbox me gustaría poder modificarlos y que mediante otro botón de comando me los colocase en el lugar correspondiente a esa vaca.
 
Lo he intentado hacer utilizando un etiqueta para poder modificar los datos de la siguiente manera:
 
Botón para buscar:
 
Private Sub CommandButton2_Click()

Rem buscar
Cells.Find(what:=TextBox1, after:=ActiveCell, LookIn:=xlFormulas, lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
ActiveCell.Offset(0, 1).Select
TextBox2 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox3 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox4 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox5 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox6 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox7 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox8 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox9 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox10 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox311 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox12 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox13 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox14 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox15 = ActiveCell
ActiveCell.Offset(0, 1).Select
TextBox16 = ActiveCell
 
Label17 = ActiveCell.Row

Range("B11").Select
 
End Sub
 
Botón para modificar datos:
 
Private Sub CommandButton4_Click()

Rem modificar datos
Label17 = "11"
Range("B11").Select
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
TextBox4 = Empty
TextBox5 = Empty
TextBox6 = Empty
TextBox7 = Empty
TextBox8 = Empty
TextBox9 = Empty
TextBox10 = Empty
TextBox11 = Empty
TextBox12 = Empty
TextBox13 = Empty
TextBox14 = Empty
TextBox15 = Empty
TextBox16 = Empty
TextBox1.SetFocus

End Sub
 
Gracias!!!