when I run the code below with the first copy of cboBox_gotfocus the code flow is as follows;
from setfocus in collect afterupdate
to box gotfocus and call box_afterupdate.
runs the code in box_after which sets focus to another textbox
box-afterupdate ends and the code returns to box_gotfocus and exits .
the code now returns to collect_afterupdate and errors on cbobox_setfocus
The error message indicates it can't set focus to cbobox.
If I run the code with the second iteration of cbobox_gotfocus, i.e the code commented out, focus is set to cbobox as expected
I hope this is understandable as I can't think of another way to explain it.
from setfocus in collect afterupdate
to box gotfocus and call box_afterupdate.
runs the code in box_after which sets focus to another textbox
box-afterupdate ends and the code returns to box_gotfocus and exits .
the code now returns to collect_afterupdate and errors on cbobox_setfocus
The error message indicates it can't set focus to cbobox.
If I run the code with the second iteration of cbobox_gotfocus, i.e the code commented out, focus is set to cbobox as expected
I hope this is understandable as I can't think of another way to explain it.
Code:
Private Sub cboCollect_AfterUpdate()
Me.cboBox.Requery
Me.cboBox.SetFocus
Me!cboBox.Dropdown
End Sub
Private Sub cboBox_GotFocus()
Me.cboBox.BackColor = RGB(218, 255, 94)
If Nz(Me.cboBox.ItemData(1), "") = "" Then
Me.cboBox = Me.cboBox.ItemData(0)
Call cboBox_AfterUpdate
End If
End Sub
Private Sub cboBox_GotFocus()
Me.cboBox.BackColor = RGB(218, 255, 94)
' If Nz(Me.cboBox.ItemData(1), "") = "" Then
' Me.cboBox = Me.cboBox.ItemData(0)
' Call cboBox_AfterUpdate
' End If
End Sub