DoCmd.OpenQuery

scrappy2

New member
Local time
Today, 00:42
Joined
Dec 12, 2008
Messages
4
Hi, I am trying to get the following bit of code to run - ill shortened it quite a bit but still not working, can someone please help

DoCmd.OpenQuery ("SELECT * FROM tblTasks;")

I keep getting an error message saying Microsoft Office Access can't find the object 'SELECT * FROM tblTasks;.'

Run-time error '7874'

Ive checked the names of the tables etc and everything is fine
 
Try using DoCmd.OpenQuery("QueryName") instead of the SQL statement. If you're going to use a SQL statement try something like the following


Dim rs as RecordSet
Dim strSQL as String

Set rs = Currentdb.OpenRecordset(strSQL)
With rs
 
Sorry. The rest of my code snippet got dropped

Dim rs as Recordset
Dim strSQL as String

Set rs = Currentdb.OpenRecordset(strSQL)
With rs
'Put your recordset code here

End With
rs.close
Set rs=Nothing
 

Users who are viewing this thread

Back
Top Bottom