Search Combo Box for a Value (1 Viewer)

&Boom

Registered User.
Local time
Today, 06:17
Joined
Sep 16, 2013
Messages
21
Hello,

I'd like to search a combo box on a subform for a string containing a (or multiple) '?' on click of a command button. The point of this is to inhibit the submission of a record with ????? as a field value (in a combo box), however it is temporarily allowed before submission of the form.

I tried this on the command button and it didn't work:

If Me!Subform.Combobox.SelText = "?" Then
MsgBox("Error")
End If

I think I am referencing the combo box on the subform incorrectly..
:banghead:
 

&Boom

Registered User.
Local time
Today, 06:17
Joined
Sep 16, 2013
Messages
21
I've attached a screen shot of the form(s) in design view. I'd like the Submit button to search ServiceLOBCbx (LOB_Abbr) for a string that is ?????. I tried referencing in VBA like that site has suggested, however I am still doing something wrong.

Any suggestions?

Thanks,
&BooM
 

Attachments

  • Capture.PNG
    Capture.PNG
    18.7 KB · Views: 85

&Boom

Registered User.
Local time
Today, 06:17
Joined
Sep 16, 2013
Messages
21
I figured it out.

Solution for anyone curious:

If Me!Subform!ComboBox.Text = "?????" Then
MsgBox("Error")
:
:
 

pr2-eugin

Super Moderator
Local time
Today, 10:17
Joined
Nov 30, 2011
Messages
8,494
The problem with using ComboBox is because they normally hide the Key column which would be a Number, and show you another data. By using Me!subFormName!comboBoxName you are accessing the bound column (which is 1, which again is your ID) but if you want you could either use what you have done above, although the best way to do is..
Code:
Me!subFormName!comboBoxName[B].Column(1)[/B]
As using .Text might throw an error when the ComboBox does not have the focus.
 

highandwild

Registered User.
Local time
Today, 10:17
Joined
Oct 30, 2009
Messages
435
Why not just limit the combobox items listed to those not containing the
?'s as well as any other criteria you want to use.

I suggest that having multiple question marks in a field is not to be advised although you may have a valid reason that you can share.
 

Users who are viewing this thread

Top Bottom