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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if then dealing with time comparison

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
US
Just a quick question. The problem is, I'm creating an auto scheduler. I have a macro named autoexec that is going to run a module. I need the module to say, if it's 8 oclock in the morning then run the first openreport, and if it's 4 oclock, then run the second openreport. I'm diving into access for work and I'm sort of a new user. I little help would do me some good.
 
Hi,

I think the "If Then Else" part is relatively simple, but one would need to know how you plan to trigger this activity. Will you have the database open continuously using a timer function or loop to run the code which checks the time? Or will you use something like Task Scheduler to open the db twice a day?

The "If Then Else" part would be something like:

If Hour(now())= 8 then
docmd.openreport("FirstReport")
elseif Hour(Now()) = 16 then
docmd.openreport("SecondReport")
End IF

Ken
 
Just off the top of my head...

dim TheHour as integer
TheHour = hour(now)

if TheHour >= 8 and TheHour <= 9 then
docmd.OpenReport(&quot;myreport&quot;, acViewPreview)
elseif TheHour >= 17 and TheHour <= 18 then
docmd.OpenReport(&quot;myotherreport&quot;, acViewPreview)
endif
 
Thanks for the reply, actually, I am running it in an even manager to run at certain times in the day. Kewo99, I used your code that you presented and it seemed to open both reports, which is good, at least it went in the right direction. I appreciate the replies. Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top