I know this has been discussed countless times but here we go again.
First, the form is visible as are the controls involved.
The form does have a subform but it is not directly involved in this error.
I have a series of comboboxes with code similar to that below.
If the sequence of events is such that the last control's dropdown is activated, there is no error generated.
If the last control in the sequence has only a single result from it's query, me.cbofour = me.cbofour.itemdata(0), then control is returned to the afterupdate event of the first control. That event then attempts to set focus to the next control, cboTwo, and the error is generated.
First, the form is visible as are the controls involved.
The form does have a subform but it is not directly involved in this error.
I have a series of comboboxes with code similar to that below.
If the sequence of events is such that the last control's dropdown is activated, there is no error generated.
If the last control in the sequence has only a single result from it's query, me.cbofour = me.cbofour.itemdata(0), then control is returned to the afterupdate event of the first control. That event then attempts to set focus to the next control, cboTwo, and the error is generated.
Code:
Private Sub cboOne_GotFocus()
Me.cboOne.BackColor = RGB(218, 255, 94)
If Nz(Me.cboOne.ItemData(1), "") > "" Then
Me.cboOne.Dropdown
ElseIf Nz(Me.cboOne.ItemData(0), "") > "" Then
Me.cboOne = Me.cboOne.ItemData(0)
Call cboOne_AfterUpdate
End If
End Sub
Private Sub cboOne_AfterUpdate()
On Error GoTo logError
Me.cboTwo.SetFocus
Exit Sub
logError:
Tracker Me.Name, "cboOne", "_AfterUpdate()", "logError:", Err.Description, Err.Number
Resume Next
End Sub