filtras registros vb6

2
 1- Esta Parte va en Formulario en load es decir form_load: Private Sub Form_Load()  Adodc1.ConnectionS tring = "Provider=Microsoft.et.!L#$.%.&'" _  "#ata Source=C*+sers*Star,in-i*#es/to0*ote2*  bd1." _  "M#$'Persist Securit3 4nfo=Fa2se"  5it Adodc1  .Command630e = adCmd6e7t  .8ecordSource = "Se2ect 9 From reservaciones"  .8efres  Set #ata-rid1.#ataSource = Adodc1.8 ecordset  #ata-rid1.Mar:ueeSt32e = dbg;ig2igt8o<8aiseCe22  .isib2e = Fa2se  nd 5it 5it Combo1  Combo1.6e7t = "fecas"  nd 5it  te7t1 = "" nd sub 2 - Esta parte va en el textbox en change es decir textbox1_change: Private Sub te7t1_Cange() !n rror -o6o error_;and 2er  5it Adodc1  4f  te7t1 >? "" 6en  .8ecordset.Fi2ter = Combo1 " L4, @9" te7t1 "9@"  Set #ata-rid1.#ataSource = Adodc1.8 ecordset  2se  .8ecordset.Fi2ter = ""  nd 4f  .8efres  nd 5it  7it Sub error_;and2er  4f  rr.Bumber = DE 6en  Msg$o7 "e2 cam0o se2eccionado no es vG2ido"H vbCritica2  2se  Msg$o7 rr. #escri0tionH vbCritica2  nd 4f nd Sub

Upload: darwin-apaza

Post on 04-Nov-2015

14 views

Category:

Documents


0 download

DESCRIPTION

Filtrar datos con DataGrid, ADO y un TextBox. Buscador de base de Datos.

TRANSCRIPT

Private Sub Form_Load()

1- Esta Parte va en Formulario en load es decir form_load:

Private Sub Form_Load()

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\Users\StarKinGizE\Desktop\hotel\bd1." & _

"MDB;Persist Security Info=False"

With Adodc1

.CommandType = adCmdText

.RecordSource = "Select * From reservaciones"

.Refresh

Set DataGrid1.DataSource = Adodc1.Recordset DataGrid1.MarqueeStyle = dbgHighlightRowRaiseCell

.Visible = False End With

With Combo1

Combo1.Text = "fechas"

End With text1 = ""End sub

2 - Esta parte va en el textbox en change es decir textbox1_change:

Private Sub text1_Change()

On Error GoTo error_Handler

With Adodc1

If text1 "" Then .Recordset.Filter = Combo1 & " LIKE '*" + text1 + "*'"

Set DataGrid1.DataSource = Adodc1.Recordset

Else

.Recordset.Filter = ""

End If

.Refresh

End With

Exit Sub

error_Handler:

If Err.Number = 3265 Then MsgBox "el campo seleccionado no es vlido", vbCritical

Else

MsgBox Err.Description, vbCritical

End If

End Sub