can't find input table or query...

  • Thread starter Thread starter Chris L
  • Start date Start date
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
 
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
 
Back
Top