SQL statement against MS access
-
I have a VB 6 Application that writes to a ms access DB. My connection works fine ( using ADO) problem is I'm trying to do a search on the table using a varible. the varible is string. I'm not sure if i have the syntax correct. PLEASE HELP Here is the code
Private Sub CmdSearch_Click() Dim strSearch As String strSearch = lblSearch.Caption adoRecords.RecordSource = "SELECT * from Volenteers where In [last_name] Like strSearch ; " adoRecords.Refresh End Sub
I get a error of syntax error in FROM clause strSearch is from a text box from a dialog form i had the same set up in a different program almost same sytax, and it works there I'm lost any help would be appreciated thanks -
I have a VB 6 Application that writes to a ms access DB. My connection works fine ( using ADO) problem is I'm trying to do a search on the table using a varible. the varible is string. I'm not sure if i have the syntax correct. PLEASE HELP Here is the code
Private Sub CmdSearch_Click() Dim strSearch As String strSearch = lblSearch.Caption adoRecords.RecordSource = "SELECT * from Volenteers where In [last_name] Like strSearch ; " adoRecords.Refresh End Sub
I get a error of syntax error in FROM clause strSearch is from a text box from a dialog form i had the same set up in a different program almost same sytax, and it works there I'm lost any help would be appreciated thanksHm - I would have written it as: for exact matches - "Select * from Volunteers Where [Last_Name] = '" & strSearch & "'" for wild cards - "Select * from Volunteers Where [Last_Name] Like '" & strSearch & "%'" I believe this will work with access, try the query builder tool. *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";
-
Hm - I would have written it as: for exact matches - "Select * from Volunteers Where [Last_Name] = '" & strSearch & "'" for wild cards - "Select * from Volunteers Where [Last_Name] Like '" & strSearch & "%'" I believe this will work with access, try the query builder tool. *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";
-
tried get error in from clause under the sql i have adorecords.recodset.refresh that gets highlighted ???
Try setting a breakpoint on the line where to set your sql variable. Run the program in the debugger and set a watch for your sql variable. Once you know *exactly* what your sql statement looks like, run it in access to make sure it is syntactically correct. You may be missing a "'" or something - *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";