2110 error (1 Viewer)

John Sh

Member
Local time
Today, 16:37
Joined
Feb 8, 2021
Messages
535
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.

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
 
what is the datatype of the fist column (.ItemData(0))?
 
what is the datatype of the fist column (.ItemData(0))?
they are all strings.
I tried changing the "call cbonow_afterupdate" to "cbonext.setfocus" with the same result.
I have a table with the steps through each combobox listed if that is of any interest.
 
you can use the Form's Timer Event though.
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)
       ' set the timer to fire
        Me.TimerInterval = 50
    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

Private Sub Form_Timer()
'kill the timer
Me.TimerInterval = 0
'Setfocus to cboTwo
Me.cboTwo.SetFocus
End Sub
 
you can use the Form's Timer Event though.
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)
       ' set the timer to fire
        Me.TimerInterval = 50
    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

Private Sub Form_Timer()
'kill the timer
Me.TimerInterval = 0
'Setfocus to cboTwo
Me.cboTwo.SetFocus
End Sub
I'm not sure what this will achieve, that is I don't understand what it is that you're doing.
If it will have a similar effect to "doevents" then I have tried that without success..
To avoid problems with the accde version, I load the subs with on error resume next.
While this gets around the problem, I would much rather find a working solution.
I will try your idea and see what happens.
 
I think I see the logic, you're giving cboOne time to settle. Unfortunately the error persists.
 
There are usually a few reasons why you can't move focus to "X". One is that "X" already HAS the focus. Another is that "X" is either disabled or invisible. The syntax you showed is wrong for the third possibility, that "X" is on a subform that is no longer open, so I'm discounting that one. Then there is the off chance is that there was a _BeforeUpdate event for the control that got triggered and was canceled.
 
There are usually a few reasons why you can't move focus to "X". One is that "X" already HAS the focus. Another is that "X" is either disabled or invisible. The syntax you showed is wrong for the third possibility, that "X" is on a subform that is no longer open, so I'm discounting that one. Then there is the off chance is that there was a _BeforeUpdate event for the control that got triggered and was canceled.
Hi Doc_man..
Thank you for the response.
Most of my forms do have a beforeupdate event which I use for history purposes but this one doesn't, nor do any of the controls on it.
All of the controls are visible at all times and none are disabled, ever.
"One is that "X" already HAS the focus." My understanding is, from a previous post and my own testing, that you can setfocus to a control that already has focus without causing an error. The control in question in my problem does not have focus.
I will try to build a cut down version of the form and table that is small enough to post.
 

Users who are viewing this thread

Back
Top Bottom