DoCmd.OpenQuery...How to capture query field info?

T

trekgoes2malaysia

In VBA, i recently tried to copy a value from a field in a query to a
variable I declared in an event procedure. I used the following code:

Dim stDocName as string
Dim getdate as integer

stDocName = "qdates"

DoCmd.OpenQuery stDocName
getdate= [dateid]
DoCmd.Close

My problem is that it doesn't work. Access does not recognise the
[dateid] field. This is different to when I use an DoCMd.OpenForm
statement where it would recognise the field I am referring to. SO my
question is ...how can I copy a field's data when running (opening) a
query in VBA as I have tried to do in my example?
 

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