Matty
...the Myth Buster
- Local time
- Today, 09:19
- Joined
- Jun 29, 2001
- Messages
- 395
Hi,
I'm developing a medical database that keeps track of referrals from doctors. Each referral record entered into the database gets a unique Referral Number. The way I'm setting that incrementing number is by taking the maximum Referral Number from the Referrals table and adding one to it.
DMax("[RefNumber]","Sleep - Referral")+1
But I've hit a snag. Very soon we may have concurrent users entering referrals, meaning the same referral number will be used (the function i'm using adds one to the last SAVED Referral Number, so both unsaved records will be assigned the same Referral Number). This will give a duplicate key error, something I'm obviously not wanting to see.
Can anyone think of a way to set incrementing Referral Numbers, without using autonumber fields or the DMax function?
I'm developing a medical database that keeps track of referrals from doctors. Each referral record entered into the database gets a unique Referral Number. The way I'm setting that incrementing number is by taking the maximum Referral Number from the Referrals table and adding one to it.
DMax("[RefNumber]","Sleep - Referral")+1
But I've hit a snag. Very soon we may have concurrent users entering referrals, meaning the same referral number will be used (the function i'm using adds one to the last SAVED Referral Number, so both unsaved records will be assigned the same Referral Number). This will give a duplicate key error, something I'm obviously not wanting to see.
Can anyone think of a way to set incrementing Referral Numbers, without using autonumber fields or the DMax function?