Using Access I have 2 different fields in a record. They cannot b.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two different fields in a record. One or the other Must have text in
it. They cannot both be Null. How do a write validation for this?
 
If you want to do this programmatically, in the Before Update event of a
form, rather than in a table-level validation rule, it would look something
like ...

If IsNull(Me!FirstTextBox) And IsNull(Me!SecondTextBox) Then
MsgBox "Please enter a value in at least one of the text boxes."
Cancel = True
End If

If you want to do it in a table-level validation rule, it would look
something like ...

(FirstField Is Not Null) Or (SecondField Is Not Null)

To define a table-level validation rule (not to be confused with a
field-level validation rule, which can not refer to any other field in the
table) select Properties from the View menu while in table design view.
 
Thanks for the quick response. What am I dong wrong? I used the table level
rule entering ("Name_last" Is Not Null) Or ("Name_Nick" Is Not Null). Note
it put quotes around the field names. Also the field names use an
underscore, must I run the name together .... Namelast? Anyway, I got no
error, the record was created with both fields null.
 
Thanks for the quick response. What am I dong wrong? I used the table level
rule entering ("Name_last" Is Not Null) Or ("Name_Nick" Is Not Null). Note
it put quotes around the field names. Also the field names use an
underscore, must I run the name together .... Namelast? Anyway, I got no
error, the record was created with both fields null.

Surround the field names with brackets!!!!!
[Name_last] Is Not Null or [Name_Nick] Is Not Null
 
It works! Thank you to everyone helping ... can't tell you how I appriciate
it! Sincerely, Flipo

fredg said:
Thanks for the quick response. What am I dong wrong? I used the table level
rule entering ("Name_last" Is Not Null) Or ("Name_Nick" Is Not Null). Note
it put quotes around the field names. Also the field names use an
underscore, must I run the name together .... Namelast? Anyway, I got no
error, the record was created with both fields null.

Surround the field names with brackets!!!!!
[Name_last] Is Not Null or [Name_Nick] Is Not Null
 
Back
Top