Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-02-2019, 02:22 AM   #1
p4man
Newly Registered User
 
Join Date: Nov 2018
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
p4man is on a distinguished road
If and then

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

p4man is offline   Reply With Quote
Old 10-02-2019, 02:35 AM   #2
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,404
Thanks: 162
Thanked 1,729 Times in 1,699 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: If and then

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.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 10-02-2019, 02:43 AM   #3
jdraw
Super Moderator
 
jdraw's Avatar
 
Join Date: Jan 2006
Location: Ottawa, Ontario, Canada;West Palm Beach, Florida
Posts: 12,127
Thanks: 81
Thanked 2,009 Times in 1,957 Posts
jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light
Re: If and then

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..

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jdraw is offline   Reply With Quote
Old 10-02-2019, 02:53 AM   #4
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,404
Thanks: 162
Thanked 1,729 Times in 1,699 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: If and then

Quote:
Originally Posted by jdraw View Post
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!

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 10:59 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World