Help on syntax Validation please (1 Viewer)

rossjackson01

Registered User.
Local time
Today, 04:22
Joined
Nov 1, 2014
Messages
21
I am new to Access and practicing.

I have made an employee table with two fields

1. Date employment commenced with the validation rule >=#05/04/1999#
and the validation rule displayed 'Date cannot be before commencement of company 05/04/1999'

2 Date employment ended with the validation rule
<=Date()
and the validation rule displayed 'Date of Employment end may not be in the future'.

Everything works as it should. However I can foresee a problem.with 1. The start date can be in the future.

Problem with 2. I want the end date not to be earlier that the start date.

So I think I need the rules in both

How do I put the 1st rule to be included with the 2nd rule? What syntax do I use between?, and where should they be placed in the validation rule line? 1 before 2, or does in not matter?

Can it be done?

Sorry for the very basic question.

Regards

Ross
 

namliam

The Mailman - AWF VIP
Local time
Today, 05:22
Joined
Aug 11, 2003
Messages
11,695
Why cant a employee start say per 1/1/2015? You allready know this today, but wont be effective untill then.

Same goes for termination, there is usually a 1 or 2 month notice period, thus today you may already know an employee is leaving per 1 feb 2015, why would you not want to enter that into your db today?
 

spikepl

Eledittingent Beliped
Local time
Today, 05:22
Joined
Nov 3, 2010
Messages
6,142
Theoretically you should validate at the lowest level possible , i.e. here, tables.

In practice, I never use table validation becuase the error messages are garbage and because any changes are PITA. Any complex rules and messages are easiest to handle in either BEforeUpdate event of any control and BeforeUpdate event of the form (google: access event sequence). Download an access db template from Micrososoft (google: access templates) and see how things get done.
 

rossjackson01

Registered User.
Local time
Today, 04:22
Joined
Nov 1, 2014
Messages
21
Namliam, spikepl.

Thank you for your prompt replies.

Namliam. I totally agree with your comments and in the real world I would probably apply your arguments. However I am just practicing and am looking for a way to increase my knowledge.

Spikepl. I will download the templates. But I do not have the knowledge to dissimilate such. I have no knowledge of 'BEforeupdate' or 'event sequence'.

Regards

Ross
 

rossjackson01

Registered User.
Local time
Today, 04:22
Joined
Nov 1, 2014
Messages
21
Done it!

I have found that the use of AND has achieved what I asked. >=#05/04/1999# And <=Date() has been submitted in both fields.

Regards

Ross
 

Users who are viewing this thread

Top Bottom