Date insertion via calandar

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I have a continuous form (that lists helpdesk requests) rather than the
user typing in a date manually, I would like the user to click on a calandar
and the date to be inserted into the appropriate field, is this difficult?
Also, there are more than one date fields, would the same calandar be used to
populate each field?

Many Thanks Tim
 
Yes, you can use the same calendar. Create a popup form named CalendatForm
and install a calendar control on the form. Name the calendar control
MyDate. Put the following code in the Open event of the form:
Me!MyDate.Value = Date()
This gets your calendar to open to todday's date.
Put the following code in the AfterUpdaye event of the calendar control:
Me.Visible = False 'More about this later.

On your continuous form, put the following code in the Enter event of each
Date field:
DoCmd.OpenForm "CalendarForm",,,,,acDialog
If Not IsLoaded("CalendarForm") Then
Exit Sub
End If
Me!NameOfDateField = Forms!CalendarForm!MyDate
DoCmd.Close acForm, "CalendarForm"
Note: You can find the IsLoaded function in a standard module in the sample
Northwind database on your computer.

acDialog in the above OpenForm code causes the code to pause until
CalendarForm becomes not visible or is closed. Then the code resumes. This
gives you the opportunity to select the date on the calendar. When you
select a date, Me.Visible = False causes the calendar form to become not
visible which in turn causes the code on the continuous form to resume. When
the code resumes, the date you selected on the calendar is filled in to the
date field from which you called the calendar form.
 
Sure, entry from a pop-up calendar can significantly reduce user errors.
Look for the Microsoft Calendar control , or do a Google search for the
dozens of other calendar forms and code that will work for you.
-Ed
 
Good morning

I can provide you with a sample database complete with calendar control that
you can simply plugin to you app.

Simply send me an email to receive your copy.

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 
Back
Top