Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000

Status
Not open for further replies.

mdot

IS-IT--Management
Mar 9, 2001
2
US
I would like a command button on a form to run a query based on the day of the week.
If today is Monday I wish to run Query1
If today is Tuesday I wish to run query2, etc.....

How can I accomplish this?

Thanks
 
Use VBA code to get the current day of the week, then you can use a series of if statements (or a select statement which is more efficient and better form, but not my personal style) to call the appropriate query.

in pseudocode:

If TodayIsSunday then
DoCmd.OpenQuery "SundayQuery"
elseif TodayIsMonday then
DoCmd.OpenQuery "MondayQuery"
...
End If

I forget which function returns the current day of the week. I'm thinking DatePart or something like that, but I may be way off. Check the help files for that part.

Good luck.
 
The Weekday Function will return the day of the week.

From the Access Help file:

Weekday Function Example
This example uses the Weekday function to obtain the day of the week from a specified date.

Dim MyDate, MyWeekDay
MyDate = #February 12, 1969# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 4 because
' MyDate represents a Wednesday.

HTH
Lightning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top