If and then (1 Viewer)

p4man

New member
Local time
Today, 10:26
Joined
Nov 10, 2018
Messages
10
I want to use the IF statment in a before update
I have tables Employees and keys
the keys table has a key no. and person1 to person5 fields
in the form the employee number is put in which shows a name
the next field is the key
I want the IF to lookup in the key table at that key number and see if employee number is in person1 or person2 to person5
if not (Else) show msg box
 

Minty

AWF VIP
Local time
Today, 17:26
Joined
Jul 26, 2013
Messages
10,355
This sounds like your data isn't stored correctly.
Whenever you have fields with repeating numbers Person1 Person2 etc. this should be a warning that your data isn't normalised.

What happens when person 6 arrives? You would have to rewrite your queries and redesign your forms. This isn't how it should be done.

You probably need a junction table KeysPeople. This would allow you to store as many keys against as many people as you need.
 

jdraw

Super Moderator
Staff member
Local time
Today, 13:26
Joined
Jan 23, 2006
Messages
15,364
Before getting too involved with the code to use if/then in an event procedure, I recommend you research Normalization. Your table structure seems suspect. Whenever you see a repeating field in a table, it is almost always a sign of improper design.

Good luck.

OOoops: I see minty has responded while I was searching for a Normalization link..
 

Minty

AWF VIP
Local time
Today, 17:26
Joined
Jul 26, 2013
Messages
10,355
OOoops: I see minty has responded while I was searching for a Normalization link..
This happens to me all the time - I'm normally just toooo slow!
 

Users who are viewing this thread

Top Bottom