I created tblMenuStartTimes
fldBreakfast
fldLunch
fldDinner
fldNights
to store the variables
on frmMenuStartTimes, I added this code
***
Option Compare Database
Private Sub txtbxBreakfast_AfterUpdate()
Dim varTime As Variant
varTime = txtbxBreakfast
'Change the time parameters to whatever you want
If varTime > #12:00:01 AM# And varTime < #8:00:00 AM# Then
DoCmd.OpenForm "frmBreakfast"
End If
End Sub
Private Sub txtbxLunch_AfterUpdate()
Dim varTime As Variant
varTime = txtbxLunch
'Change the time parameters to whatever you want
If varTime > #10:00:00 AM# And varTime < #3:00:00 PM# Then
DoCmd.OpenForm "frmLunch"
End If
End Sub
Private Sub txtbxDinner_AfterUpdate()
'Change the time parameters to whatever you want
If varTime > #4:00:00 PM# And varTime < #9:00:00 PM# Then
DoCmd.OpenForm "frmDinner"
End If
End Sub
Private Sub txtbxNights_AfterUpdate()
'Change the time parameters to whatever you want
If varTime > #9:00:00 PM# And varTime < #2:00:00 AM# Then
DoCmd.OpenForm "frmNights"
End If
End Sub
***
What variable do I use after the logon to check the
varTime to know when to bring up the correct form
As it is, if the textbox is unbound and I put a time
in there, then the form opens up, but close the form
and the time is lost, so the textboxes are now bound
to store the time variables, but no event fires off to
open a form.
Thanks again for your help.
DJ
-----Original Message-----
I will see what I can do with this.
Thank you very much
DJ
-----Original Message-----
Hi DJ
In the form that the user will use to select the time, place the following
code in the afterupdate of the control where they type the time in. Set the
format of the control to Medium Time
Private Sub NameOfControl_AfterUpdate()
Dim varTime As Variant
varTime = [NameOfControl]
'Change the time parameters to whatever you want
If varTime > #12:00:01 AM# And varTime < #8:00:00 AM# Then
DoCmd.OpenForm "frmBreakfast"
End If
If varTime > #10:00:00 AM# And varTime< #3:00:00 PM# Then
DoCmd.OpenForm "frmLunch"
End If
End Sub
Just add additional lines of code for each form you
want
to open and specify
the time ranges. Add some Error Handling or Validation to account for
incorrect input format by the user.
lwells
:
Thank you for your reply
I really need to put this into a form so that it can be
changed the the user. I not sure how to adapt the
code
to
do that.
DJ
-----Original Message-----
DJ,
I have something similar to this so see if you can make
something like this
work:
Private Sub Form_Load()
Dim varTime As Variant
varTime = Time()
If varTime > #12:00:01 AM# And varTime < #12:00:00 PM#
Then 'Open your form
If varTime >= #12:00:00 PM# And varTime < #6:00:00 PM#
Then 'Open your form
If varTime >= #6:00:00 PM# And varTime < #11:59:00 PM#
Then 'Open your form
I am sure you can adopt some of this to your use
lwells
:
I have a main form (frmMain) with four command buttons
to
display
one of 4 forms:
frmDay
frmLunch
frmDinner
frmNight
When a user logs in currently it opens to frmMain and
the
user selects one of the command buttons.
cmdOpenFrmDay
cmdOpenFrmLunch
cmdOpenFrmDinner
cmdOpenFrmNight
What I need to do is on a separate form be able to set
a time of day for each form to open automatically at
the time set.
i.e. Logs on
frmMain still opens
then if the time is set to 11:00 am then frmOpenLunch
opens
etc
Any suggestions on how I can do this?
Thank you in advance for your help
DJ
.
.
.