Assume the following --
Calendar form is named PFrmCalendar
Calendar is named MyCalendar
Textbox on form is named MyDate
Put the following code in the Open event of PFrmCalendar:
Me!MyCalendar.Value = Date()
Put the following code in the AfterUpdate evnt of MyCalendar:
Me.Visible = False
Create a button beside the textbox MyDate. Put the following code in the
Click event of the button:
DoCmd.OpenForm "PFrmCalendar",,,,,acDialog
If SysCmd(acSysCmdGetObjectState, acForm, "PFrmCalendar") <> 0 Then
Me!MyDate = Forms!PFrmCalendar!MyCalendar.Value
DoCmd.Close acForm, "PFrmCalendar"
End If
If you have two textboxes named StartDate and EndDate and you want to fill
both of them when the calendar opens, put the following code in the Click
event of the button:
DoCmd.OpenForm "PFrmCalendar",,,,,acDialog
If SysCmd(acSysCmdGetObjectState, acForm, "PFrmCalendar") <> 0 Then
Me!StartDate = Forms!PFrmCalendar!MyCalendar.Value
DoCmd.Close acForm, "PFrmCalendar"
DoCmd.OpenForm "PFrmCalendar",,,,,acDialog
If SysCmd(acSysCmdGetObjectState, acForm, "PFrmCalendar") <> 0 Then
Me!EndDate = Forms!PFrmCalendar!MyCalendar.Value
End If
End If