Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adodc search problems

Status
Not open for further replies.

chrsab

Programmer
May 24, 2002
44
GB
Hello

I am using a adodc component which is connected to a ms access table. I am displaying the information in a datagrid. I can display, add, save etc. The one problem I am facing is trying to search and only display the search results (not a find). The following code is what I am using:

Private Sub CmdSearch_Click()

Dim search As String

search = "SELECT * FROM Table1 WHERE Name = Mr Flibble"

Adodc1.RecordSource = search

Adodc1.Recordset.Update

DataGrid1.Refresh

End Sub

I don't get any errors but nothing really happens.

Any help, please.

Thanx
 
I believe that you need to refresh the ADODC.
Code:
Adodc1.RecordSource = search
Adodc1.Refresh

zemp
 
And you should also consider dropping the ADODC and bound controls and start using ADODB and load the grid with code.

search the net for BOUND vs UNBOUND controls to see reasons for change

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
For the record I agree with Frederico. I haven't used bound controls in years. Bottom line for me was the increase in control.

zemp
 
I did use adodc1.refresh to start with but got the error 'Syntax error in query, incomplete query clause. Then i get the error message : 'Method Refresh of object 'IAdodc' failed', i think it has something to do with the I being before the adodc but can't explain why.
 
Probably a minor point but as Name isn't a number field you would need to enclose your WHERE clause criteria in single quotes. e.g.
Code:
"SELECT * FROM Table1 WHERE Name = [red]'[/red]Mr Flibble[red]'[/red]"
If you've just changed the criteria for posting you cna obviously ignore my point.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanx HarleyQuinn, but i gave that a go and that didn't work either.
 
Did you get a different error message with 's in or was it the same?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Did you try zemp's and my suggestions in conjunction? e.g.
Code:
Private Sub CmdSearch_Click()

Dim search As String

search = "SELECT * FROM Table1 WHERE Name = 'Mr Flibble'"

Adodc1.RecordSource = search

Adodc1.Refresh

DataGrid1.Refresh

End Sub
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Hello

Yeap I tried them both but still got the same error

Thanx
 
Syntax error in query generally means syntax error in query. (Not trying to be sarcastic here, what I'm saying is that there aren't weird obscure reasons to get this error that I'm aware of.) For example, did you really call your table table1? Is there in fact a field in your table called Name? Did you try running your query in Access, and did it work there? Try those kinds of things, and post your corrected code if you're still having trouble, so we can have a look at it.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top