debug calender in combo box

C

cporter

I have a dialog box for selecting dates. It has two combo boxes
programmed as calendars and the code is listed below. When the form
opens the focus is on the first combo box and the calendar is visible.
If the user selects a date from the open calendar an error message,
"object variable or With block variable not set", appears. If the user
clicks on the combo box first then selects the date there is no error.
What are my best options for preventing the error? Do I need to shift
the focus when the form opens or is there a better option?




Option Compare Database
Dim cboOriginator As ComboBox

Private Sub ocxCalendar_Click()
cboOriginator.Value = ocxCalendar.Value
cboOriginator.SetFocus
ocxCalendar.Visible = False
Set cboOriginator = Nothing
End Sub

Private Sub ocxCalendar_Updated(Code As Integer)

End Sub

Private Sub StartDate_Click()

End Sub

Private Sub StartDate_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
Set cboOriginator = StartDate
ocxCalendar.Visible = True
ocxCalendar.SetFocus


If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If

End Sub

Private Sub StopDate_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
Set cboOriginator = StopDate
ocxCalendar.Visible = True
ocxCalendar.SetFocus


If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If

End Sub
 
C

cporter

Found the answer to my own problem. I set the visible property of the
calendar to "no" and solved the issue. Thanks for looking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top