Computing.Net > Forums > Database > Validation rule for access

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Validation rule for access

Reply to Message Icon

Name: mondeh
Date: July 23, 2009 at 14:37:57 Pacific
OS: Windows Vista
Product: Microsoft Access 2003 eng (full product)
Subcategory: General
Comment:

I am working on a Microsoft Access project and need a validation rule for the job number.

I need it in the form 09-140

where the 09 represents the current year, and the 140 an incremental number which starts from 1 and automatically increases by 1 with each addition of a new job.

I would like the rule to autofill as I enter information for a new job, and for the 09 to automatically change to 10 when we go into the year 2010 etc.

For example:

For the first 3 jobs this year the job number would auto-fill:

09-001
09-002
09-003

and then if there was not a job until 2010, the next job number would be:

10-004


Is this possible?

Thanks in advance,

Jon



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: July 27, 2009 at 17:48:23 Pacific
Reply:

Simple. You create two fieldes in the data base. One for the number using Access Auto data type which increments by one every time a new record is created. You also have a field that records the date the record is created.

When you come to display it you concentate just the year from the date and the data from the Auto fill field.

In VB his would be:

JobNo = DatePart("yyyy", Date) & "-" & Autofield

The Datepart function produces a four digit year. You should be able to work out how to reduce that to a two gigit year although I would stick with four digit years. It was two digit years that got us into the Y2K problem.

Stuart


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Validation rule for access

Validation Rule for Date www.computing.net/answers/dbase/validation-rule-for-date/25.html

Access '07 require field if other field www.computing.net/answers/dbase/access-07-require-field-if-other-field-/735.html

Shortcut for new record in Access? www.computing.net/answers/dbase/shortcut-for-new-record-in-access/120.html