changing a query criteria field in DAO and ADO

  • Thread starter Thread starter Paul James
  • Start date Start date
P

Paul James

I would like to use VBA to change the criteria for a query field to set it
equal to the value entered by a user in a form field. I'm currently using
DAO in my class modules, but I'm planning on migrating to ADO within the
next couple of months, so it would help if I had code to do this in both.

It would help if any example could use the following names for my objects:

query: qryOvertime
query field: StartPeriod

form: frmMgtReport1
form control: cboStartPeriod

Thanks in advance,

Paul
 
I don't quite understand. If you're doing it by building an SQL string, or
by just including a form reference in the query syntax, then whether you're
using ADO or DAO to access the query will make no difference.

So I don't see any difference between the two. (Though there might be
something about the parameters collection depending on what you intend doing
with the query.)

If you're just asking about how to do it... then all you need to do is have
forms![frmMgtReport1]![cboStartPeriod] on the criteria row below
StartPeriod. Or build the SQL string including a reference to the same
thing.
 
all you need to do is have
forms![frmMgtReport1]![cboStartPeriod] on the criteria row below
StartPeriod. Or build the SQL string including a reference to the same
thing.

Of course! Duh.

Thanks, Rob.

Paul
 

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

Similar Threads


Back
Top