If time =

rikklaney1

Registered User.
Local time
Today, 07:12
Joined
Nov 20, 2014
Messages
157
I have a question about time. This works....

If Me.autotime.Value = #7:00:00 am# Then
DoCmd.OpenForm "startup"


but this doesn't.....

If Me.autotime.Value = Me.Ctl1shiftstart.Value Then
DoCmd.OpenForm "startup"


even though me.ctl1shiftstart.value is 7:00:00 am.

What is the reason for one working but not the other?
 
Last edited:
Your question doesn't tell us enough to be sure.

First, is Access running "behind the scenes" for this to even have a place where code is running? How does "Me.Autotime" get a value, and what value is in it?

Second, just a hint: When you specify ".Value" you are wasting keystrokes. For Access objects that have a .Value property, the .Value property is the default selection. You can therefore omit .Value when you want the current value associated with the control. That would make it easier to read, too.

Third, what do you do if the Access code hiccups and then runs at 07:00:01 AM? What do you do if the code, for whatever reason, runs twice within the same second (theoretically possible in the general case)?

Fourth, as it was typed, you appear to have a syntax error in your first comparison. You need that time constant to be something like "#7:00:00 AM#" (i.e. symmetrical bracketing) but you don't seem to have that.
 
It actually turned out to not be working because the value of ctl1shiftstart was a default value. If I changed it to a lookup the code worked fine. As to the .value not being needed that is a handy little piece of info right there. Thanks!
 

Users who are viewing this thread

Back
Top Bottom