I have a combo box on a form which drops down once the user has typed into it. I want the dropdown to "disappear" if the user backspaces to an empty string and I thought the best way to do so would be to set the focus to a random text box and then return the focus back straight afterwards. Unfortunately, I keep getting an error saying that Access can't move the focus to the random textbox. I'm convinced it is because I am trying to set the focus back to the combo box before the text box has gained focus but I dont know which event to place the combobox.setfocus in order to switch back to the combobox.
At the moment, the barebones of the code is:
Expand|Select|Wrap|Line Numbers
- Private Sub cboLookup_Change()
- Dim sNewLookup As String
- sNewLookup = Nz(Me.cboLookup.Text, "")
- If Len(sNewLookup) <> 0 Then
- Me.Text13.SetFocus
- Exit Sub
- End If
- Me.cboLookup.RowSource = sSQL
- Me.cboLookup.Dropdown
- End If
- bLookupKeyPress = False
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Text13_GotFocus()
- Me.cboLookup.SetFocus
- End Sub