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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access saved query versus VBA query 1

Status
Not open for further replies.

adamcbest

MIS
Joined
Feb 6, 2006
Messages
38
Location
US
I'm having a problem with a VBA query in Access. FIrst off, I wrote a query in design view and saved it to make sure it worked. This query pulled all the info that it shoudl have pulled. However, when i go into the code behind of a button and try to open this query. It comes up with no records. I tried it by using the one i had saved and by putting the SQL code into a string variable and running it against the string. Either way it finds no records. Here is my recordset declaration and open line:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

dim strSQL as string
strSQL = "My SQL statement"

rs.Open strSQL, CurrentProject.Connection, adOpenStatic, adLockOptimistic

This has worked for me several times in the past with less extensive SQL code. I don't see how it could be my strSQL statement because it is the exact same code that is in the saved query that works.. any ideas
 
Remember the ADO wildcard is % (percent) not *

- you might perhaps make it a bit easier to assist if you posted the actual statement

Roy-Vidar
 
i did not know that.. that was my problem. thank you.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top