QueryDefs in Macro?

P

Paul S Panoff

I haven't used QueryDefs before ams am having problems.
I am getting a run time error of object type mismatch when using the
following code in a macro.
The "Map Extract" query is an existing query in the database that runs
fine outside of the macro.

Public Sub UpdatePersonValues()
' use to update the map-Prsn field with unique sequential values that
' represent the color codes for the routes within each cycle

Dim rsQ As Recordset
Dim svOfc As String, svCyc As Integer, svRte As String
Dim colorCnt As Integer

Set rsQ = CurrentDb.QueryDefs("Map Extract").OpenRecordset() <---run
time error here!

'begin loop to go thru all records from query

With rsQ
 
S

Steve Schapel

Paul,

Should be...
Set rsQ = CurrentDb.OpenRecordset("Map Extract")

By the way, this is not a macro.

- Steve Schapel, Microsoft Access MVP
 
P

Paul S Panoff

Thanks for the suggestion, but the results are the same. I still get the
type mis-match runtime error.
 
S

Steve Schapel

Paul,

Please post the SQL view of the Map Extract query.

- Steve Schapel, Microsoft Access MVP
 

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