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
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