can't find input table or query...

C

Chris L

Hi
I get an error message saying the jet engine can't find
the input table or query strSQL after running the code
below:

'********
'DEFINE VARS
'*******
Dim db As Database
Dim rs As Recordset
Dim strSQL As String

Set db=CurrentDb()

'**********
'1. string to hold SQL statement (build query)
'**********
strSQL = "SELECT * FROM tblREV04"

'**********
'2. EXECUTE ABOVE STATEMENT
'*********
Set rs = db.OpenRecordset ("strSQL")

BLAH BLAH BLAH

If I remove the quotes around strSQL I get an error
message of data type mismatch...

What did I forget?

Thanks
CL
 
J

Jen

Hi Chris,

1. It's cause your code is looking for the literal
string "strSQL". Change the line of code ...

Set rs = db.OpenRecordset ("strSQL")
to
Set rs = db.OpenRecordset (strSQL)

2. The reason why you're getting the data type mismatch
when you removed the quotes is because you need to fully
qualify what type of recordset object you want to use.
Change the line of code...

Dim rs as Recordset
to
Dim rs as DAO.Recordset

Regards,
Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top