PC Review


Reply
Thread Tools Rate Thread

changing a query criteria field in DAO and ADO

 
 
Paul James
Guest
Posts: n/a
 
      6th Feb 2005
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


 
Reply With Quote
 
 
 
 
Rob Oldfield
Guest
Posts: n/a
 
      6th Feb 2005
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.


"Paul James" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Paul James
Guest
Posts: n/a
 
      7th Feb 2005
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query criteria based on a changing criteria list bwilk77 Microsoft Excel Misc 4 27th May 2009 04:03 PM
Query criteria based on a changing criteria list bwilk77 Microsoft Excel Misc 0 27th May 2009 03:40 PM
How to display Table Field names AND Field Definitions in a Report ? (ditto for query fields & criteria) Will Microsoft Access 1 29th Aug 2007 01:14 PM
changing a query criteria field in DAO and ADO Paul James Microsoft Access Form Coding 2 7th Feb 2005 04:55 AM
changing a query criteria field in DAO and ADO Paul James Microsoft Access Queries 2 7th Feb 2005 04:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:13 AM.