John, i'm still having difficulty getting this to work properly.
here is the VBAcode:
Private Sub Form_Load()
Text1 = Now()
If [locktrigger] < [Text1] Then
DoCmd.OpenForm "frmLogin1"
ElseIf [locktrigger] < [Text1] Then
DoCmd.OpenForm "terms field"
Else
MsgBox "Values are equal"
End If
End Sub
I have preset the [locktrigger] to "8/20/11 8:30:22 AM"
[Text1] is 8/19/11 6:45:36 PM
which should result in the form "frmLogin1" being open but results in
the msgbox "Vales are equal" instead. This is confusing because the
values clearly are not equal.
When i preset the [locktrigger to "8/10/11 8:30:22 AM"
[Text1] is 8/19/11 6:45:36 PM
which should result in the form "terms field" opening but results in
nothing happening at all.
I"ve turned both fields into "short date" format thinking this may be
the problem but that didn't have any effect.
Can you see anything that i'm doing wrong?
Yes. And I've told you twice now, and you've ignored it both times.
Text1 is a VBA VARIABLE which is not dimensioned and never used.
[Text1] is a FORM CONTROL that is never set to anything and is unnecessary.
Form controls are one thing.
Variables in your code are a different thing.
You're testing the expression [locktrigger] < [Text1] twice and expecting to
get different results. I'll guess that you want to open the (badly named] form
[terms field] if locktrigger is LATER than the current date/time (accurate to
microseconds), and form frmLogin if it's EARLIER, but that's a pure guess.
[locktrigger] is something, I don't know what it is, because you have (twice
now) declined to tell me, and my clairvoyance is on the blink.
Replace your entire routine with:
Option Explicit ' this should be the first line in every module
' It will detect undimensioned variables and warn you to fix them
Private Sub Form_Load()
If Me![locktrigger] < Now Then
DoCmd.OpenForm "frmLogin"
ElseIf [locktrigger] > Now Then
DoCmd.OpenForm "[terms field]"
Else
MsgBox "Miracle! You typed in a time accurate to microseconds!"
End If
End Sub
If you want to see the current time in a textbox on the form you can set that
textbox to Now, but it won't affect the logic.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also
http://www.utteraccess.com