Good day,
I am trying to code for the following:
If the current time of day is less than 8:30 am and greater than 5:30 pm,
exit sub.
Please help. Thanks
Bob Quintal - 17 Jul 2007 18:03 GMT
> Good day,
>
[quoted text clipped - 4 lines]
>
> Please help. Thanks
Use the timer function to return the number of seconds since
midnight
dim starttime as single
dim enddtime as single
starttime = 60*60*8.5 ' secs/min * mins/hr * 8 & half hours
endtime = 60*60*17.5
. If timer >= starttime and timer < enddtime then
exit sub
end if

Signature
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Bob Quintal - 18 Jul 2007 00:58 GMT
OOPS. Forgot an else statement to invert the logic.
>> Good day,
>>
[quoted text clipped - 14 lines]
>
> . If timer >= starttime and timer < enddtime then
ELSE
> exit sub
> end if

Signature
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Paterson - 17 Jul 2007 18:30 GMT
you cannot be <8:30 AND >5:30. If that is the way your code is try <8:30
OR>5:30
> Good day,
>
[quoted text clipped - 4 lines]
>
> Please help. Thanks
Steve - 17 Jul 2007 18:34 GMT
Sorry, that is what I meant. Code for less than 8:30 am Or greather than
5:30 pm. Could you post that again please.
> you cannot be <8:30 AND >5:30. If that is the way your code is try <8:30
> OR>5:30
[quoted text clipped - 7 lines]
> >
> > Please help. Thanks
Douglas J. Steele - 17 Jul 2007 18:31 GMT
If Now() < #08:30:00# Or _
Now() > #17:30:00# Then
Exit Sub
End If

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Good day,
>
[quoted text clipped - 4 lines]
>
> Please help. Thanks
Douglas J. Steele - 17 Jul 2007 18:34 GMT
Oops, sorry, that should be
If Time() < #08:30:00# Or _
Time() > #17:30:00# Then
Exit Sub
End If

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> If Now() < #08:30:00# Or _
> Now() > #17:30:00# Then
[quoted text clipped - 9 lines]
>>
>> Please help. Thanks
Steve - 17 Jul 2007 18:44 GMT
Ahh, that did the trick. Very odd, I copy and pasted what you put in, and
access changed it to:
If Time() < #8:30:00 AM# Or _
Time() > #5:30:00 PM# Then
Exit Sub
End If
But is works.
> Oops, sorry, that should be
>
[quoted text clipped - 16 lines]
> >>
> >> Please help. Thanks
Douglas J. Steele - 17 Jul 2007 18:49 GMT
What gets displayed between the # delimiters will be impacted by how your
Time format has been set through Regional Settings in the Control Panel.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Ahh, that did the trick. Very odd, I copy and pasted what you put in, and
> access changed it to:
[quoted text clipped - 27 lines]
>> >>
>> >> Please help. Thanks
Steve - 17 Jul 2007 19:44 GMT
Well thank you, that worked great.
> What gets displayed between the # delimiters will be impacted by how your
> Time format has been set through Regional Settings in the Control Panel.
[quoted text clipped - 30 lines]
> >> >>
> >> >> Please help. Thanks
Marshall Barton - 17 Jul 2007 21:14 GMT
>If the current time of day is less than 8:30 am and greater than 5:30 pm,
>exit sub.
If you are looking to check if the current tome is outside
that interval, use:
If Not (Time >= #8:30# And Time <= #17:30#) Then Exit Sub

Signature
Marsh
MVP [MS Access]