Populating only one text box instead of populating another text box

  • Thread starter Thread starter Alex Martinez
  • Start date Start date
A

Alex Martinez

Hello,

I am using Access 2002 and in my form I have these text boxes:

Delivered Faxed Mailed Hand Carried

Only one of the text box must be populated, the problem is that my user
populates (input a two digit letter AB) two or more of the text box. I want
Access to show an error message saying that you alread populate a text box.
For example - Let's say that I have text box Delivered populated and the
user populates Mailed I want to have some sort of error message explaining
that a text box has alread been populated. Any tips or suggestions will be
appreciated. Thank you.
 
Alex,

One approach to this would be to put code on the Before Update event of
each textbox, to validate the entry. For example, on the Before Update
event of the Mailed textbox, the code might be like this...

If IsNull(Me.Delivered) And IsNull(Me.Faxed) And
IsNull(Me.Hand_Carried) Then
' proceed
Else
MsgBox "Method already entered"
Cancel = True
Me.Mailed.Undo
End If

Another approach would involve a change to your table design. For
example, you could have a field (Number data type) for the Method, and
another field for the TwoLetterCode. On the form, you could represent
the Method field by an Option Group, with 4 option buttons, one for each
of your Delivered, Faxed, etc choices, and the entry of the 2 letter
code would apply to whichever option is selected for the Method. Apart
from removing the possibility that more than one Method can be chosen,
this approach would have other advantages as well, for exmple it would
be a lot simpler if you ever needed to produce summary statistics or
whatever for this data.
 
Back
Top