run-time setfocus error 2110 on combo box

Sanchocow

Registered User.
Local time
Today, 08:57
Joined
Feb 25, 2008
Messages
10
I get a cannot set focus to the control error on a combo box that is populated by what a user enters in a text box, but only on certain entries...the user types in an area code and the combo box populates with all of the contacts with that area code. The area codes that get the error are ones with a lot of entries, but the maximum for the combo box is set over what any of them could be. Any ideas how to get past this?
Thanks.
 
How about posting the code for the function that is giving you the error? We might spot something.
 
Code

Here's the code for the sub that's giving the error, only happens on some entries though

Private Sub txtWorkPhone_Change()
Dim strSQL, strPhone
If Me.txtWorkPhone.Text Like "(***)" Then
strPhone = Me.txtWorkPhone.Text
strSQL = "Select Distinct WorkPhone, Company from ContactPerson Where WorkPhone Like '" & Me.txtWorkPhone.Text & "*'"
Me.Combo131.RowSource = strSQL
Me.Combo131.Requery
Me.Combo131.Visible = True
Me.Combo131.SetFocus Error Here
Me.txtWorkPhone.Visible = False
Me.Combo131.Text = strPhone
Me.Combo131.Dropdown
Me.Combo131.SelStart = 6
Me.Combo131.SelLength = 6
End If


End Sub
 
Are you aware that the Change event of a TextBox occurs at each keystroke of the user?
 
yeah but the if statement only triggers the code when the text in the box is the area code
 
Do you have the TextBox on top of the ComboBox so the visibility switch you do seems to make a TextBox into a ComboBox? BTW, replacing the RowSource of a ComboBox *will* cause a cbo to requery. Your requery is redundant.
 
yeah that's how it is, then when you select a number it changes back to a textbox, puts the number in the textbox and the afterupdate event of the textbox does a findrecord for the phone number and displays the rest of the contact info
 
Don't take this wrong but is there something wrong with doing it all with the ComboBox?
 
Probably not, but anyway I don't know what I did but I seem to have fixed the error. It may actually have been just taking out the requery...
 
Just tested it...that's what it was, awesome thanks
 
Glad you got it sorted. Thanks for posting back with your success.
 

Users who are viewing this thread

Back
Top Bottom