How do you add a pop-up calendar to an existing Access file?

M

MeaganNW

I need to know how to add a pop-up calendar to an existing Microsoft Access
file. I need to add the pop-up calendar next to the date section on the
file. Please help! Any information will be greatly appreciated!
Thanks!
 
J

James

Hi,

Create a new, empty form in design view. Click the crossed tools (More
Controls) that is in your toolbox and find the Calendar Control in your extra
controls. Your cursor should turn into a cross with a little hammer beside
it. Draw a box the size of the calendar you want on the form. Your
calendar should start automatically.

Enter the following code into the Double Click Event Procedure of your VB
Code.

Private Sub actlCalendar_DblClick()
Dim dtmDate As Date
'To set the date control to date selected on the calendar
dtmDate = Me.ActiveControl.Value
DoCmd.Close acForm, Me.Name 'Closes form once value is selected
Screen.ActiveControl.Value = dtmDate
End Sub

Then (we're getting close to the end...:) )
create a text box on the form that you wish to have the calendar pop up on
and place this code in the double click event procedure

Private Sub TxtEndDate_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmCalendar"
End Sub

Run your form, and hopefully, double clicking inside your text box will
start the Calendar form. Double click the desired date which will then enter
that date into your text box.

Hope it works out for you...
 
L

lbartley

Meagan this is as simple as it gets. I assume you already have a date label
on your form. Rename the label co cbodate and save it. On the form where
you want to create the calendar click on tools and then click on more tools
and select Calendar Control 10 if you are running Access 2002. Once this is
done click anywhere on the form you would like the calendar to be. Once you
have the calendar created rename the calendar label to ocxcalendar once this
is done go to the cbodate label in design view and right mouse click on
cbodate go to properties go to event and on mouse down click on event
procedure and then to the right of that click on the little square with dots.
Once this is up paste this into the hilighted code area.

Private Sub cboDate_MouseDown(Button As Integer, Shift As Integer, x As
Single, Y As Single)
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboDate) Then
ocxCalendar.Value = cboDate.Value
Else
ocxCalendar.Value = Date
End If
End Sub

This will work. It took me quite awhile to figure it out so good luck.
Lee
 
Top