PDA

View Full Version : Automatic Client_ID and Pet_ID



Jurodj
09-27-2007, 12:46 PM
I would like somebody to help me in this issue.

Databases:
Clients (fields: Client_ID, Lastname, Firstname)
Pets (fields: Pet_ID, Pet_Name, Client_ID)

Someone opens a form to insert a new client (or pet owner).
Suppose a client name: John Smith
The Client_ID must be in the following format:
First Lastname letter: In this case "S" + First Firstname letter:"J" + the value of a Counter: e.g. 0001 for this first one.
In other words, for this client his ID will be:
SJ001
For a other new client with the same initials like Josh Stetson it will be SJ002 (001 was the last one in the series).
Peter Kayak: KP001
Ann Parker: PA001
Amber Peterson: PA002, and so on.

Second:
The PET_ID has to be formed by the Client_ID + a counter.
For instance, Client SJ001 has 2 cats. The Pet ID for the first one will be SJ001-01 and SJ001-02 for the second pet.

How can I achive this automatically when inserting new pet owners and their pets.

Can somebody help me?:dunno

OBP
09-28-2007, 06:31 AM
This one is quite tricky, creating the first part with the Owner Initials is very easy, however the recordset check that is required to find any previous SJ or PAs will require a Select query using both a wild card and the Max function.
Can you post a zipped copy of the database for me to "play" with?