I have inherited an Access 2000 db and was asked to upgrade it to 2003. I did the convert to 2000-2003 format and it seems to be working fine.
However, I have a listbox that when it is loaded an OnClick event is added.
ctl.OnClick = "=ShowDaysEvents"
When I click on the listbox I get the following error:
"The expression On Click you entered as the event property setting produced the following error: The object doesn't contain the Automation Object 'ShowDaysEvents'.
Here is the code for the sub:
Public Sub ShowDaysEvents()
'On Error GoTo ErrTrap_ShowDaysEvents
' This procedure is called when the user clicks on one of the command
' buttons on frmCalendar which correspond to dates in the month.
' The selection criteria (filter) are fed to the command button Tag property
' when the calendar is first loaded.
Dim strCriteria As String
Dim strNumber As String
Dim strList As String
Dim ctrl As Control
Dim varItm As Variant
Set ctrl = Screen.ActiveControl
If ctrl.Name Like "cmd*" Then
' This section of code runs when user clicks the command button
' corresponding to the number of the day
strCriteria = ctrl.Tag
' Is there a user-applied filter?
If g_Is_CalFilter Then
strCriteria = ctrl.Tag & " and " & g_CalFilter
End If
g_strDayNum = Mid$(ctrl.Name, 4)
g_strList = Trim("List" & g_strDayNum)
g_DateClicked = ctrl.StatusBarText ' the actual date represented by this command button
' Are there any events listed for the day clicked?
If Me(g_strList).ListCount > 0 Then
g_AddEvent = False
DoCmd.OpenForm "frmCalDayList", , , strCriteria
Else
' There are no events; open a form so that a user WITH RIGHTS
' can add an event. Or, if NO RIGHTS, advise the user that
' there are no events for the date selected.
If g_AllRights Then
g_msg = "There are no events for this date. " _
& "Do you want to add a new event on this date?."
If MsgBox(g_msg, vbYesNo) = vbYes Then
g_AddEvent = True
DoCmd.OpenForm "frmCalDetail", , , , acFormAdd
End If
Me!Text189.SetFocus
Else
MsgBox "There are no records to view for this date."
End If
End If
ElseIf ctrl.Name Like "List*" Then ' User clicked an individual event in a listbox
g_strList = ctrl.Name
If ctrl.ItemsSelected.Count > 0 Then
g_AddEvent = False
For Each varItm In ctrl.ItemsSelected
strCriteria = "[EventID] = " & ctrl.ItemData(varItm)
If g_AllRights Then
DoCmd.OpenForm "frmCalDetail", , , strCriteria
Else
DoCmd.OpenForm "frmCalDetail_Read", , , strCriteria
End If
Next varItm
End If
End If
End Sub
What is going on here?
Thanks,
enak
However, I have a listbox that when it is loaded an OnClick event is added.
ctl.OnClick = "=ShowDaysEvents"
When I click on the listbox I get the following error:
"The expression On Click you entered as the event property setting produced the following error: The object doesn't contain the Automation Object 'ShowDaysEvents'.
Here is the code for the sub:
Public Sub ShowDaysEvents()
'On Error GoTo ErrTrap_ShowDaysEvents
' This procedure is called when the user clicks on one of the command
' buttons on frmCalendar which correspond to dates in the month.
' The selection criteria (filter) are fed to the command button Tag property
' when the calendar is first loaded.
Dim strCriteria As String
Dim strNumber As String
Dim strList As String
Dim ctrl As Control
Dim varItm As Variant
Set ctrl = Screen.ActiveControl
If ctrl.Name Like "cmd*" Then
' This section of code runs when user clicks the command button
' corresponding to the number of the day
strCriteria = ctrl.Tag
' Is there a user-applied filter?
If g_Is_CalFilter Then
strCriteria = ctrl.Tag & " and " & g_CalFilter
End If
g_strDayNum = Mid$(ctrl.Name, 4)
g_strList = Trim("List" & g_strDayNum)
g_DateClicked = ctrl.StatusBarText ' the actual date represented by this command button
' Are there any events listed for the day clicked?
If Me(g_strList).ListCount > 0 Then
g_AddEvent = False
DoCmd.OpenForm "frmCalDayList", , , strCriteria
Else
' There are no events; open a form so that a user WITH RIGHTS
' can add an event. Or, if NO RIGHTS, advise the user that
' there are no events for the date selected.
If g_AllRights Then
g_msg = "There are no events for this date. " _
& "Do you want to add a new event on this date?."
If MsgBox(g_msg, vbYesNo) = vbYes Then
g_AddEvent = True
DoCmd.OpenForm "frmCalDetail", , , , acFormAdd
End If
Me!Text189.SetFocus
Else
MsgBox "There are no records to view for this date."
End If
End If
ElseIf ctrl.Name Like "List*" Then ' User clicked an individual event in a listbox
g_strList = ctrl.Name
If ctrl.ItemsSelected.Count > 0 Then
g_AddEvent = False
For Each varItm In ctrl.ItemsSelected
strCriteria = "[EventID] = " & ctrl.ItemData(varItm)
If g_AllRights Then
DoCmd.OpenForm "frmCalDetail", , , strCriteria
Else
DoCmd.OpenForm "frmCalDetail_Read", , , strCriteria
End If
Next varItm
End If
End If
End Sub
What is going on here?
Thanks,
enak