T
Tom
I have a form that uses the Lebans Month calendar. The calendar is
used to set a date range for a query. The form also has a checkbox.
The idea is the user will check this checkbox if the dataset from the
query is correct. This in turn makes a command button visible.
The problem I'm having is if the user checks the checkbox in error,
then unchecks and then calls the calendar to select another date range
I get the following error:
The month calendar class instance you passed to this function is
INVALID! You must instantiate the Month Calendar class object before
you call this function. The code behind the sample Form shows you how
to do it in the Forms load event.
'This must appear here!
'Create an instance of our class
Private Sub Form_Load()
Set mc = NewclsMonthCal
'You must set the cass hWndFrm prop!!
mc.hWndForm = mc.hWnd
The code for the checkbox is:
Private Sub CheckBox_AfterUpdate()
If CheckBox.Value = -1 Then
Command40.Visible = True
Label44.Visible = True
Else
Command40.Visible = False
Label44.Visible = False
End
End If
End Sub
The code for the Month Calendar is:
Private Sub cmdDateRange_Click()
' Retrieve the currently selected date(s).
' Call our Function to display the Calendar
Dim blRet As Boolean
Dim DateStart As Date
Dim DateEnd As Date
' If the control is NULL then use Today's date.
DateStart = Nz(Me.CollectionDate.Value, Date)
DateEnd = DateStart + 7
' Use named parameters for clarity
blRet = ShowMonthCalendar(clsMC:=mc, StartSelectedDate:=DateStart, _
EndSelectedDate:=DateEnd)
If blRet = True Then
Me.CollectionDate.Value = DateStart
Me.txtEndDate.Value = DateEnd
Else
' Add any message here if you want to
' inform the user that no date was selected
Me.CollectionDate.Value = Null
Me.txtEndDate.Value = Null
End If
End Sub
Thanks in advance
used to set a date range for a query. The form also has a checkbox.
The idea is the user will check this checkbox if the dataset from the
query is correct. This in turn makes a command button visible.
The problem I'm having is if the user checks the checkbox in error,
then unchecks and then calls the calendar to select another date range
I get the following error:
The month calendar class instance you passed to this function is
INVALID! You must instantiate the Month Calendar class object before
you call this function. The code behind the sample Form shows you how
to do it in the Forms load event.
'This must appear here!
'Create an instance of our class
Private Sub Form_Load()
Set mc = NewclsMonthCal
'You must set the cass hWndFrm prop!!
mc.hWndForm = mc.hWnd
The code for the checkbox is:
Private Sub CheckBox_AfterUpdate()
If CheckBox.Value = -1 Then
Command40.Visible = True
Label44.Visible = True
Else
Command40.Visible = False
Label44.Visible = False
End
End If
End Sub
The code for the Month Calendar is:
Private Sub cmdDateRange_Click()
' Retrieve the currently selected date(s).
' Call our Function to display the Calendar
Dim blRet As Boolean
Dim DateStart As Date
Dim DateEnd As Date
' If the control is NULL then use Today's date.
DateStart = Nz(Me.CollectionDate.Value, Date)
DateEnd = DateStart + 7
' Use named parameters for clarity
blRet = ShowMonthCalendar(clsMC:=mc, StartSelectedDate:=DateStart, _
EndSelectedDate:=DateEnd)
If blRet = True Then
Me.CollectionDate.Value = DateStart
Me.txtEndDate.Value = DateEnd
Else
' Add any message here if you want to
' inform the user that no date was selected
Me.CollectionDate.Value = Null
Me.txtEndDate.Value = Null
End If
End Sub
Thanks in advance