1,105,295 Community Members

vb6 search in datagrid

Member Avatar
problematic:)
Light Poster
31 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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. :)

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Try the following -

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

Set Datagrid1.Recordsource = Adodc1
Member Avatar
problematic:)
Light Poster
31 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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. :)

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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
Member Avatar
problematic:)
Light Poster
31 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Datagrid1.Recordsource = rs

Datagrid1.Refresh
Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Yes, it should.

Question Answered as of 3 Years Ago by AndreRet
Member Avatar
Bile
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article