I have a main form called Interviewers and a subform called Ratings. The subform also has a command button that is a date picker. The field it updates on the subform is called Date2. The On Click property of the command button is set with this: =OpenCalendar("Ratings","Date2",1.792,3.439). When I click on the command button
I get a run time error 2450 cannot find the "Ratings" form. Then When I debug it, it goes to this part of the code: Set frm = Forms(strForm) Below is the code from the module.
The Date Picker works great as long as it is on a form by it self. It's when I put it on a subform that I get the error. Thanks any assistance is super appreciated
Option Compare Database
Option Explicit
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
I get a run time error 2450 cannot find the "Ratings" form. Then When I debug it, it goes to this part of the code: Set frm = Forms(strForm) Below is the code from the module.
The Date Picker works great as long as it is on a form by it self. It's when I put it on a subform that I get the error. Thanks any assistance is super appreciated
Option Compare Database
Option Explicit
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