Changing Criteria Based on the Weekday (1 Viewer)

JoeGKushner

New member
Local time
Yesterday, 18:23
Joined
Jun 23, 2015
Messages
9
I have inherited a module that looks at the weekday (date). If it's Monday, it runs one query, if it's Tuesday, it runs another.

Can I put the criteria itself directly in the query or should I just keep it 'simple'?

I say 'simple' because after it runs, it's exported to Excel, and it takes the name of the query, which can sometimes cause some confusion as people see the Excel workbook with one name one day and another name another day.
 

Ranman256

Well-known member
Local time
Yesterday, 19:23
Joined
Apr 9, 2015
Messages
4,339
open the reporting form, with a combo box
the combo has dow, mon,tue,wed.
it gets set upon open , form_load() event
set combo to the day,
cboDoW = format(date(),"www")
the query opens this
Code:
on btnOpen_click()
vQry = "qs" & cboDoW
docmd.openquery vQry

you must make a query for every DOW
qsMon
qsTue
qsWed
 

plog

Banishment Pending
Local time
Yesterday, 18:23
Joined
May 11, 2011
Messages
11,638
My gut tells me these different queries could be combined into one query, using the Day of the week as criteria. Are all of these queries based on the same datasources?
 

MarkK

bit cruncher
Local time
Yesterday, 16:23
Joined
Mar 17, 2004
Messages
8,180
If it's Monday, it runs one query, if it's Tuesday, it runs another.
This doesn't make sense in principle. Time is a scalar quantity just like dollars or inches, so you should use that quantity itself. For example, you would never run one query for 6 inches, and a different query for 7 inches, and a different query for 8 inches. Rather, you would pass the measure to the query regardless of its value. Similarly, with time, pass the time itself to the query, no need to pre-process how much time.
 

Users who are viewing this thread

Top Bottom