changing a query criteria field in DAO and ADO

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
 
R

Rob Oldfield

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.
 
P

Paul James

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
 
Top