VBAhole22
Registered User.
- Local time
 - Today, 01:41
 
- Joined
 - Jan 18, 2002
 
- Messages
 - 117
 
I am writing an Access project in Access 2k against a MS SQL Server db:
I have a form/subform setup where the user enters information on the form and when they tab out of the last field I validate it using the Before_Update event. If all of the data passes validation the record is entered. I then want to put up a message box telling the user the unique id that has been assigned to the record in the autonmuber field.
Currently I am doing this with a stored procedure:
Alter Procedure GetUniqueIDBack
As
SELECT TOP 1 Collection
FROM Collections
ORDER BY Collection DESC
return
That gets called in this same event.
I have to problems with this:
1. It's always a record behind. I guess because before update occurs before update. I know it's one behind because the number that gets transferred to my subform is the right one. Would there be a better event that occurs after the record is in?
2. I know from reading posts here that this isn't the best way to do this because another user in a multiuser environment could sneak in and enter a record before this proc ran. What's a better way to do this?
 I have a form/subform setup where the user enters information on the form and when they tab out of the last field I validate it using the Before_Update event. If all of the data passes validation the record is entered. I then want to put up a message box telling the user the unique id that has been assigned to the record in the autonmuber field.
Currently I am doing this with a stored procedure:
Alter Procedure GetUniqueIDBack
As
SELECT TOP 1 Collection
FROM Collections
ORDER BY Collection DESC
return
That gets called in this same event.
I have to problems with this:
1. It's always a record behind. I guess because before update occurs before update. I know it's one behind because the number that gets transferred to my subform is the right one. Would there be a better event that occurs after the record is in?
2. I know from reading posts here that this isn't the best way to do this because another user in a multiuser environment could sneak in and enter a record before this proc ran. What's a better way to do this?