rutgermons
asked on
autonumber with a variable prefix
folks
I have an autonumber eg BTU 1001
when I hit insert it has to be BTU1002
though the prefix BTU can be different
so I might have
CTU 233
the next would be CTU234
how can I build a trigger
so when I insert a new record i.e with the prefix
BTU and then save it it will take the last number and add one eg
BTU1003 (BTU1002+1)
when I then put in
CTU and save then CTU235 will crop up
all help will do
rutger
I have an autonumber eg BTU 1001
when I hit insert it has to be BTU1002
though the prefix BTU can be different
so I might have
CTU 233
the next would be CTU234
how can I build a trigger
so when I insert a new record i.e with the prefix
BTU and then save it it will take the last number and add one eg
BTU1003 (BTU1002+1)
when I then put in
CTU and save then CTU235 will crop up
all help will do
rutger
ASKER
could u assist with an example pls?
r
r
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Inside the trigger
1. look up the NextNumber for that prefix
2. Grab it
3. Update that record with the next number
If the Prefix isn't found, insert it and start at 1 or whatever number you want.