1,105,232 Community Members

vb6 search code in datagrid

Member Avatar
vonnoy
Light Poster
31 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi, im new in vb6
how to search in datagrid where every keyword you type wil display the record
found in database? here's my code in saving
pls ned help here....this is our thesis
God Bless>thanks.

Sub search()
'search if student is registered then
With ado
    .ConnectionString = connectdb
    .RecordSource = "Select * from info where Barcode = '" & Text2 & "'"
    .Refresh

    If .Recordset.RecordCount > 0 Then
    Text3 = ado.Recordset!Barcode
    Text4 = ado.Recordset!fname
    Text5 = ado.Recordset!lname
    Text6 = Date

'student attendance check
    Call add

 End If




End With


End Sub

 Public Sub add()
'save to attendance record
With adoadd.Recordset
.AddNew
!Barcode = Text3
!First_Name = Text4
!Last_Name = Text5
!Date = Text6
.Update
MsgBox "save", vbInformation, "message"

Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
End With
DataGrid1.Refresh
End Sub
Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

how to search in datagrid where every keyword you type wil display the record
found in database?

You want to search in datagrid or search record in database?

Member Avatar
vonnoy
Light Poster
31 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

yes, thats it,like if i type on the txtbox automatically display on the datagrid
but dont know how to code it.
can u help me?

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

Ok. So when you type on textbox then there are data display on datagrid.
Use textbox change event to make searching every you type a word on textbox.
This is an example of searching using datagrid. Modified as you needed.

Private Sub Text1_Change()
 Set rs = New ADODB.Recordset
        rs.CursorType = adOpenDynamic
        rs.LockType = adLockOptimistic
        rs.Open "SELECT * FROM Login where fname  like " & "'%" & Text1.Text & "%'", Conn, , , adCmdText

    Set DataGrid1.DataSource = rs
    DataGrid1.Columns(0).Width = 2000
    DataGrid1.Columns(1).Width = 2000

    DataGrid1.AllowAddNew = False
    DataGrid1.AllowArrows = True
    DataGrid1.AllowDelete = False
    DataGrid1.AllowUpdate = False
End Sub
Member Avatar
vonnoy
Light Poster
31 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thank you so much, it works.

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

You're welcome.
Don't forget to mark this thread as Solved.
Happy Coding.

Member Avatar
deepakbshitole
Newbie Poster
7 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
This may be useful to find data from Grid.
Please find attached project.
It will be able to find and replace the text from MSFlexGrid's Cells

Attachments Find_And_Replace_Grid.zip (9.07KB)
Question Answered as of 1 Year Ago by Jx_Man and deepakbshitole
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: