I have a calendar procedure that works well. However, since I use it in so many forms, I was trying to get it to be one called procedure passing only the form name and control name to it. HOwever, I keep getting a "The control number you speciifed is greater than teh number of controls". which I have no ide means. I am calling the procedure by using the below. Also, can this even be done?
Private Sub HRStartDate_Click()
Call ShowCalendar(Me, Me.HRStartDate)
The actual procedure is:
Public Sub ShowCalendar(frmName As Form, ctlName As Control)
'Used for the MonthCalendar control
Dim blRet As Boolean
Dim dtStart As Date
Dim dtEnd As Date
Dim ctl As Control
'First check to see if the control is locked, if it is, then cannot show
'calendar as field should not be changed.
If frmName.Controls(ctlName).Locked = True Then
dtStart = Nz(frmName.ctlName.value, 0)
dtEnd = 0
blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
If blRet = True Then
frmName.ctlName = dtStart
' Add any message here if you want to
' inform the user that no date was selected
PS: This is code from, I think Allen Browne's site, it works as he originally created, I am just trying to ttake it a step further.