Avatar of travishaberman
travishaberman

asked on 

VB Access DB Constraints

Hi Experts,

I am working with Access and VB.  I need the to enforce some constraints at the DB.  Specifically, have 4 yes/no fields in a table {F1, F2, F3, F4}.

I want the DB to enfoce the following constraint....

           IF (F1 OR F2 OR F3) = True
           THEN F4 must be true

... How can I add a constraint like this to my DB?  To be clear, I know that I can check data as it goes into the DB and validate that the user has appropriatly entered F4=True if any of the other fields are... This is not good enough - I want the DB to through an error back at them....

Thanks so much,

-TRAVIS
Visual Basic ClassicMicrosoft Access

Avatar of undefined
Last Comment
travishaberman
Avatar of Raynard7
Raynard7

access will not do this for you.  it just is not designed to check for things like this.  you could in other larger rdms, but not in access.

as mentioned you can do this with vb but  you can not make the db do it for you.
Avatar of Rey Obrero (Capricorn1)
using a form for data entry you can check the values and enforce the rule in the
before update event of the form.
Avatar of stevbe
stevbe

There is single table record validation in Access.

right click on the table (while it is open in design mode) and select properties ... you enter the validation rule and text (what you want displayed when the rule is broken)

there is even an example in the help file. (press F1 when you cursor in in either of these properties)

Steve
ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of travishaberman

ASKER

THAT IS PERFECT.. Thank you!
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo