Hi all,
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.setfoc us in order to switch back to the combobox.
At the moment, the barebones of the code is:
It gives the error in the cboLookup_Chang e on the SetFocus line which makes sense - I just can't work out how to give the text box focus before returning it back to the combo box. All help is most appreciated!
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.setfoc us in order to switch back to the combobox.
At the moment, the barebones of the code is:
Code:
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
Code:
Private Sub Text13_GotFocus() Me.cboLookup.SetFocus End Sub
Comment