filtras registros vb6

Post on 04-Nov-2015

15 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

top related