Macro to Autmatically Change Dates

G

Guest

I know nothing about macros but I really need one to automatically change
dates in queries. I currently have in the criteria:

Between #1/22/2007# And #1/26/2007#

Each week I have to go in and manually change it for that week, is there a
macro I could run that would change it automatically for me?
 
S

Steve Schapel

Michelle,

Whereas it would theoretically be possible to do this, by externally
manipulating the SQL property of the query, there is a much simpler
approach.

On a form, which will be open at the time that your query criteria are
applied, put two textboxes. This is where the user will enter the date
criteria. If applicable, you can set up default values for these
textboxes, so they would normally automatically show "Monday this week"
or whatever. Then, in the Criteria of the Query, in the place of the
"hard-coded" dates that you showed in your example, you would use the
equivalent of this instead:
Between [Forms]![NameOfYourForm]![StartDate] And
[Forms]![NameOfYourForm]![EndDate]
 

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