I have a date picker calendar that is on a command button and is used to select a date for an Access text box form field that sits next to it. It works fine except that I would like to have it open and update that field to todays date. I tried setting the default value of the field to = Date() but it only opens with the last date that was set on that field. Below is the code for the module of the calendar date picker.
Also on the command button I have the on click event set to =OpenCalendar("zSetReportCriteria","Report Start",10.59,7). zSetReportCriteria is the name of the form and Report Start is the name of the field that gets updated. Any ideas
Option Compare Database
Dim ctrl As Control
Dim frm As Form
Const centimeter = 567
Function OpenCalendar(strForm As String, strCtrl As String, intLeft, intTop)
Set frm = Forms(strForm)
Set ctrl = frm(strCtrl)
frm("msCal".Visible = True
frm("msCal".Left = intLeft * centimeter
frm("msCal".Top = intTop * centimeter
frm("msCal".Value = Date
End Function
Function CloseCalendar()
frm(ctrl.Name).SetFocus
frm("msCal".Visible = False
End Function
Sub SetDate()
frm(ctrl.Name).Value = frm("msCal".Value
frm(ctrl.Name).SetFocus
frm("msCal".Visible = False
End Sub
Also on the command button I have the on click event set to =OpenCalendar("zSetReportCriteria","Report Start",10.59,7). zSetReportCriteria is the name of the form and Report Start is the name of the field that gets updated. Any ideas
Option Compare Database
Dim ctrl As Control
Dim frm As Form
Const centimeter = 567
Function OpenCalendar(strForm As String, strCtrl As String, intLeft, intTop)
Set frm = Forms(strForm)
Set ctrl = frm(strCtrl)
frm("msCal".Visible = True
frm("msCal".Left = intLeft * centimeter
frm("msCal".Top = intTop * centimeter
frm("msCal".Value = Date
End Function
Function CloseCalendar()
frm(ctrl.Name).SetFocus
frm("msCal".Visible = False
End Function
Sub SetDate()
frm(ctrl.Name).Value = frm("msCal".Value
frm(ctrl.Name).SetFocus
frm("msCal".Visible = False
End Sub