By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,538 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

SQL OpenQuery

100+
P: 102
Front end= MS Access/VBA 2010
Back end= MS SQL Server 2008

I have the following code that produces the following error message: Microsoft Access can't find the object 'Select * FROM dbo_DB WHERE userDB='FGulley' AND db='001';'.

gblSQL = "Select * FROM dbo_DB WHERE userDB= '" & gblUser & "' AND db=" & "'001';"
DoCmd.OpenQuery gblSQLWhat is wrong?

Thanks.
Jan 19 '15 #1

✓ answered by jforbes

I think you want to use DoCmd.OpenRecordset instead of DoCmd.OpenQuery as OpenQuery will only open a named Query in the Access Database.

DoCmd.OpenQuery
DoCmd.OpenRecordset

Share this Question
Share on Google+
1 Reply


jforbes
Expert 100+
P: 1,107
I think you want to use DoCmd.OpenRecordset instead of DoCmd.OpenQuery as OpenQuery will only open a named Query in the Access Database.

DoCmd.OpenQuery
DoCmd.OpenRecordset
Jan 19 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.