Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I make two fields mutually exclusive at the table level? 1

Status
Not open for further replies.

postermmxvicom

Programmer
Jun 25, 2007
114
US
I have two fields which are mutually exclusive. Only one should be filled out always. Never both, never none. Making the two fields one is not an option I will consider, though perhaps it is technically possible. Now I have the form set up to prevent the user from entering data in both fields, but I was wondering if I can enforce this at the table level.

I want to enforce it there also if I can.

I suppose I can always check to see if both are filled out before any logic executes that depends on only one field being filled out. But, it'd be nice just to know it is enforced at the table level instead.
 



Hi,

How about one mandatory field that can contain only one of two values?

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 


I guess it would be TWO mandatory fields:

the first, with one of two specified values and

the second, for whatever the user is required to enter with respect to the first.

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
Skip,

I had thought about that, if I understand you correct. That is, make one field a kind of logical switch which indicates what kind of thing the next field represents...perhaps I can/should/will do that. Will the way I am doing things now or cramming them into one field will present more problems? I have to think that out...my gut tells me no to the one field scenario, but this has not been backed up rationally by me yet.

Are there any other ways to enforce this kind of situation?
 
IsNull(field1 + field2) AND Not IsNull(field1 & field2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

I am a little new at this, so it took me a minute to figure out this needed to go into the form's validation rule. (I didn't even know that existed. Yes, I am that green) However, your solution worked like a charm. Thanks for conjuring up that expression for me, had I known about form validation - it would still have taken time to figure out that logic.

Course Clear - You got a card

Thanks - Aaron






Skip,

Thanks for weighing in. I don't feel your solution is right for this particular problem, but I really do have to consider it.

Thanks - Aaron
 
I meant the tables validation rule...not form.

Is there any way to edit posts here or am I blind?
 
Oh, and uh, I guess I put this in the wrong forum. I read this as "Microsoft: Access Forums" not "Microsoft: Access Forms"...so, if anyone with the power to do so wants to move this into the table forum, then, good to go...


:/

(No wonder I couldn't find the answer when I was searching since I was looking through form questions not table ones)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top