Mandatory Fields

G

Guest

Hi All,

I know how to make a field mandatory by using the 'required' property of a
table. However i have two fields 'Reference1' and 'Reference2', one of these
must be filled in but not both before the record can be saved. The values are
not unique and could be used several times. I would like to do this at the
table level but the user enters the details on a form so this could be okay
if it is not possible to do it at the table level. Can anyone help me with
this?

Thanks
Emma
 
B

Brendan Reynolds

You can do it with a table-level (not field-level) validation rule. To
access the table-level validation rule, open the table in design view and
select Properties from the View menu. The validation rule could be something
like ...

[TestOne] Is Not Null Xor [TestTwo] Is Not Null

.... where 'TestOne' and 'TestTwo' are the names of the two fields.
 
S

Steve Schapel

Emma,

In Design view of the table, select Properties from the View menu. In
the Validation Rule property, enter this...
[Reference1] Is Not Null Or [Reference2] Is Not Null
Use the Validation Text property to define the message that the user
will see if the Validation Rule is not complied with.
This validation check will only be triggered when the record is updated.
If you need the check at other times, you will need code behind the form.
 
G

Guest

Wouldn't it be better to use the AfterUpdate events of the two text boxes on
your form to set the value of the other text box to Null when a value is
entered into one of the text boxes ... that way you'll never have to put up a
message to the user saying "You can only enter this or that."?

Cheers ...
 
S

Steve Schapel

Frank,

This idea does not cater to a situation where the user has not entered
anything in either field. Also, the After Update event of a textbox is
triggered when you delete existing data from it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top