C
CalgaryDataGirl
I am trying to run a pop-up calendar in Access (I am a SQL girl... not
familiar with VB code) and I can't seem to figure out why I keep getting this
error:
Run-time error '91':
Object variable or With block variable not set
Can anyone help tell me what is wrong here? Here is my code:
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboStartDate
' Unhide the calendar and give it the focus
Calendar6.Visible = True
Calendar6.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
Calendar6.Value = cboOriginator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub cboEndDate_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboEndDate
' Unhide the calendar and give it the focus
Calendar6.Visible = True
Calendar6.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
Calendar6.Value = cboOriginator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub Calendar6_Click()
' Copy chosen date from calendar to originating combo box
cboOriginator.Value = Calendar6.Value ----- this is where it is
highlighted ----
' Return the focus to the combo box and hide the calendar and
cboOriginator.SetFocus
Calendar6.Visible = False
' Empty the variable
Set cboOriginator.Value = Nothing
End Sub
Thanks! Stacy
familiar with VB code) and I can't seem to figure out why I keep getting this
error:
Run-time error '91':
Object variable or With block variable not set
Can anyone help tell me what is wrong here? Here is my code:
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboStartDate
' Unhide the calendar and give it the focus
Calendar6.Visible = True
Calendar6.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
Calendar6.Value = cboOriginator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub cboEndDate_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboEndDate
' Unhide the calendar and give it the focus
Calendar6.Visible = True
Calendar6.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
Calendar6.Value = cboOriginator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub Calendar6_Click()
' Copy chosen date from calendar to originating combo box
cboOriginator.Value = Calendar6.Value ----- this is where it is
highlighted ----
' Return the focus to the combo box and hide the calendar and
cboOriginator.SetFocus
Calendar6.Visible = False
' Empty the variable
Set cboOriginator.Value = Nothing
End Sub
Thanks! Stacy