Stop Record Insert

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have 3 controls on a form. If the 2 controls equal a certain
combination and the 3rd control is null, how can I stop the record
from being inserted?
 
1. Open your table in design view.

2. Open the Properties box.

3. Beside the Validation Rule in the Properties box, enter an expression
like this (substituting your field names for A, B, and C, and the bad total
for 100):

([A] Is Null) OR ( Is Null) OR ([A] + <> 100) OR ([C] Is Not Null)

Be sure to use the Validation Rule in the Properties box, not the one in the
lower pane of table design (which is the rule for a field, not for the
table.)

If the table-level validation rule idea is new, here's an introduction:
http://allenbrowne.com/ValidationRule.html
 
Allen, Thanks for the quick post. I neglected to say one thing. It's
an ADP. The tables are in SQL.



1. Open your table in design view.

2. Open the Properties box.

3. Beside the Validation Rule in the Properties box, enter an expression
like this (substituting your field names for A, B, and C, and the bad total
for 100):

([A] Is Null) OR ( Is Null) OR ([A] + <> 100) OR ([C] Is Not Null)

Be sure to use the Validation Rule in the Properties box, not the one in the
lower pane of table design (which is the rule for a field, not for the
table.)

If the table-level validation rule idea is new, here's an introduction:
   http://allenbrowne.com/ValidationRule.html

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.




I have 3 controls on a form.  If the 2 controls equal a certain
combination and the 3rd control is null, how can I stop the record
from being inserted?- Hide quoted text -

- Show quoted text -
 
You can set the SQL table to reject non-null values. You can also run a
trigger or a stored procedure which will identify and delete any rows that
have a null value in 1 or more fields. There are no triggers in Access, but
a Delete query can accomplish the same thing.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Allen, Thanks for the quick post. I neglected to say one thing. It's
an ADP. The tables are in SQL.



1. Open your table in design view.

2. Open the Properties box.

3. Beside the Validation Rule in the Properties box, enter an expression
like this (substituting your field names for A, B, and C, and the bad
total
for 100):

([A] Is Null) OR ( Is Null) OR ([A] + <> 100) OR ([C] Is Not Null)

Be sure to use the Validation Rule in the Properties box, not the one in
the
lower pane of table design (which is the rule for a field, not for the
table.)

If the table-level validation rule idea is new, here's an introduction:
http://allenbrowne.com/ValidationRule.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.




I have 3 controls on a form. If the 2 controls equal a certain
combination and the 3rd control is null, how can I stop the record
from being inserted?- Hide quoted text -

- Show quoted text -
 
Arvin Meyer said:
You can set the SQL table to reject non-null values.

That should, of course, read:

You can set the SQL table to reject null values.
 
Back
Top