hi! i'm using a ms access 2003 and vb6. I have a textbox and a datagrid controlled by an adodc. can anyone tell me how can i display the data that I need in the datagrid. example: i entered a lastname "cruz". I want the datagrid to display customers that has cruz surnames? can that be possible. please help me. :)

Recommended Answers

All 7 Replies

Try the following -

Adodc1.Recordsource = "SELECT * FROM MyTableName WHERE FieldName LIKE 'cruz%'"

Set Datagrid1.Recordsource = Adodc1

Is this a command button or in the form_load? well it may kinda twisting but my code is something like this

Private Sub Search_Click()
Set RS = New Recordset
RS.Open " select * from records where firstname or lastname = '" & txtsearch.text & "'", cn, adOpenDynamic, adLockOptimistic
If RS.EOF Then
MsgBox "Record not found"
Else
(this is my problem, I need the datagrid to display the lastnames that ends with cruz)
End If
End Sub

then I also need to display on the datagrid the lastnames and firstnames that would match in the txtsearch

it's really twisting my head out. thanks for the help. :)

Else
(this is my problem, I need the datagrid to display the lastnames that ends with cruz)
End If
End Sub

Add the following -

Else
'this is my problem, I need the datagrid to display the lastnames that ends with cruz)
Datagrid1.Recordsource = rs
Datagrid1.Refresh
End If
End Sub

will this display the records that i need to display in the datagrid??

Datagrid1.Recordsource = rs

Datagrid1.Refresh

Yes, it should.

Well,Hi! May know how will I be able to find the Sum of all the Entries in my Datagrid Column with a Title Total retrieved from an AccessDB field named the same name?

Bile, this thread is SOLVED AND it belongs to Problematic.:)

Please open your own thread and we will reply on that, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.