Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

HELP with search text1.text_Change and DataGrid

$
0
0
so I'm trying to make a code using datagrid and a textbox where everytime the user types in a letter or a number the datagrid narrows it's search

this is my code

Code:

Private Sub txtSearch_Change()

Call connect
With rs
    .ActiveConnection = con
    .CursorLocation = adUseClient
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
End With

rs.Open "SELECT * FROM account WHERE LastName LIKE '" & Replace(txtSearch.Text, "'", "") & "%'"
Set Me.DataGrid1.DataSource = rs

End Sub

Function dgAct()
Call connect
With rs
    .ActiveConnection = con
    .CursorLocation = adUseClient
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    End With
   
rs.Open "SELECT * FROM account WHERE LastName LIKE '" & Replace(txtSearch.Text, "'", "") & "%'"

Set Me.DataGrid1.DataSource = rs
con.Close

End Function
Private Sub Form_Load()
Call connect
With rs
    .ActiveConnection = con
    .CursorLocation = adUseClient
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    End With
rs.Open "SELECT * FROM account"
Set Me.DataGrid1.DataSource = rs
End Sub


Viewing all articles
Browse latest Browse all 21090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>