What's the best way to limit the users' choices on input? (again)

creolejazz

Registered User.
Local time
Today, 05:33
Joined
Jun 28, 2007
Messages
55
I'm terribly sorry to have to ask this a second time but my original thread is now apparently corrupt (same title, see below) and the thread is now unavailable. I have not been able to view/read the five replies to my original thread so hope you're willing to help again.

I have a form with a field called Boy/Girl. I would like to limit the entries in that field to either "B" or "G". It may be left blank but if anything at all is entered in that field it must be only either B or G. What's the best way to accomplish this?

Thanks again and sorry for the hassle. I have advised the board admin about the corrupt thread.
 
in the properties window of your combo you can set the limit to list option to "Yes"
 
A combobox for two items is really a bit of an overkill. Yo insure that the user leaves the field blank or enters only a "B" or a "G" use this in the BeforeUpdate event of your textbox.

Code:
Private Sub txtBoyGirl_BeforeUpdate(Cancel As Integer)
 If Not IsNull(txtBoyGirl) Then
   If txtBoyGirl <> "b" And txtBoyGirl <> "g" Then
     MsgBox "This field must be Empty or Contain a 'B' or a 'G'"
     Cancel = True
     txtBoyGirl.SelStart = 0
     txtBoyGirl.SelLength = Len(txtBoyGirl.Text)
   End If
 End If
End Sub

Simply replace txtBoyGirl with the actrual name of your textbox.
 

Users who are viewing this thread

Back
Top Bottom