Recordset problem

T

Tim

Hi everyone,

I created a recordset from query. But, it didn't work.
Could anyone can help me?


Dim db As Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("select ID from qryemp;")

Debug.Print rst.Fields("ID").Value


Thanks in advance.

Tim.
 
T

Tim

Ken,

The error message is:

Run-time error 3131:
Syntax error in From clause.

Thanks.

Tim.
 
K

Ken Snell

You need to put square brackets around the query name because you have a
hyphen as part of the name:

Set rst = db.OpenRecordset("select ID from [qryemp-ID];")
 

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