Calendar Control

G

Guest

Hi

My boss wants to run a report using the calendar control, as it takes him
too long to type the numbers in to a paramter prompt for the query.
I have designed a form which has two fields

Startdate
Enddate

I wish to fully automate the procedure so that my boss only has to click two
dates for the report to run and also by using only one calendar control
within the form.
Below is the code so far, however I am struggling to find a way to make the
code work for updating the Enddate field. Can someone please advise which
event would work for triggering the second part of the code needed
Code to setting the value for Startdate, as you can see I have used the
Form_Open event to start the first bit of code offf, however I am struggling
for the event to trigger the next bit off. I know it will be simple and I
will kick my self later, but please help

Option Compare Database
Dim cboOriginator As ComboBox

Private Sub Form_Open(Cancel As Integer)
Set cboOriginator = Startdate
Calendar4.Visible = True
Calendar4.SetFocus
Calendar4.Value = Date
End Sub

Private Sub Calendar4_Click()
cboOriginator.Value = Calendar4.Value
cboOriginator.SetFocus
Calendar4.Visible = False
Set cboOriginator = Nothing
End Sub
 
W

Wolfgang Kais

Hello Richard.

richard said:
Hi

My boss wants to run a report using the calendar control, as it
takes him too long to type the numbers in to a paramter prompt for
the query. I have designed a form which has two fields

Startdate
Enddate

I wish to fully automate the procedure so that my boss only has to
click two dates for the report to run and also by using only one
calendar control within the form.
Below is the code so far, however I am struggling to find a way to
make the code work for updating the Enddate field. Can someone please
advise which event would work for triggering the second part of the
code needed Code to setting the value for Startdate, as you can see
I have used the Form_Open event to start the first bit of code off,
however I am struggling for the event to trigger the next bit off. I
know it will be simple and I will kick my self later, but please help

Option Compare Database
Dim cboOriginator As ComboBox

Private Sub Form_Open(Cancel As Integer)
Set cboOriginator = Startdate
Calendar4.Visible = True
Calendar4.SetFocus
Calendar4.Value = Date
End Sub

Private Sub Calendar4_Click()
cboOriginator.Value = Calendar4.Value
cboOriginator.SetFocus
Calendar4.Visible = False
Set cboOriginator = Nothing
End Sub

How about something like this (not tested):

Private Sub Calendar4_Click()
cboOriginator.Value = Calendar4.Value
cboOriginator.SetFocus
Calendar4.Visible = False
If cboOriginator.Name = "Startdate" Then
Set cboOriginator = Enddate
Calendar4.Visible = True
Calendar4.SetFocus
Calendar4.Value = Date
Else
Set cboOriginator = Nothing
DoCmd.OpenReport....
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top