Microsoft Access Database Engine Cannot Find the Input Table or Query

JithuAccess

Member
Local time
Today, 02:10
Joined
Mar 3, 2020
Messages
325
Hello Guys,

This is my Code:

Dim db As Database
Dim rst As Recordset
Dim STRSQL As String

Set db = CurrentDb()

STRSQL = "Select [Table1.ID] from [Table1];"

Set rst = db.OpenRecordset(STQSQL)

I am getting an error message like:

1612455472475.png


I have this Table1 in my Database. I have no idea why I am getting this Error. Could you kindly let me know what is the Error.

Thanks
 
Look at how you spell STRSQL :(

You should have Option Explicit at the tope of ALL your modules?

That would have highlighted your error?

Also please start using code tags, you have over 100 posts on here, and should know way before now :-(
 
Look at how you spell STRSQL :(

You should have Option Explicit at the tope of ALL your modules?

That would have highlighted your error?

Also please start using code tags, you have over 100 posts on here, and should know way before now :-(

Thanks a lot. There wasn't Option Explicit at the Top of my Code Window. It works perfect when I add this.
 
Thanks a lot. There wasn't Option Explicit at the Top of my Code Window. It works perfect when I add this.
A simple addition of Option Explicit would not fix the error?. It would highlight the error?
 
A simple addition of Option Explicit would not fix the error?. It would highlight the error?
I am not sure about that but this is working perfect now. Before your suggestion for adding Option Explicit I put the Code like this:

Code:
Dim db As Database
Dim rst As Recordset
Dim STRSQL As String

Set db = CurrentDb()

Set rst = db.OpenRecordset(Select [Table1.ID] from [Table1])

End Sub

And this was working.

Thanks
 
You have STRSQL = "Select [Table1.ID] from [Table1];"

and you use Set rst = db.OpenRecordset(STQSQL) :(
 

Users who are viewing this thread

Back
Top Bottom