Locking a field (1 Viewer)

temacc

New member
Local time
Today, 03:18
Joined
Jul 11, 2002
Messages
6
Hi,

I need to lock a field while I'm generating the next sequential number. Does anyone have any code examples or the function you would use to lock a field. Does the .locked lock the field in the table or only on the form??

Thanks
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:18
Joined
Feb 19, 2002
Messages
43,374
The locked property refers to the form control. What are you trying to accomplish by locking a field? Are you talking about the seed number for your sequential number generator? If that is the case, you need to use a transaction because two tables need to be updated in sync. If one of the updates fails, you want the ability to roll back the other one. Look up Transaction in help.

The logic is:
Begin Trans
update seed number to get next sequential number
Insert New row
If Insert is Ok
Commit
Else
Roll Back
End IF

Now if you have to Roll Back, you'll have to decide if you want to loop in the background and try again or if you have to go back to the user to have him fix some bad data that caused the record to not save.

When you use Autonumbers, Access takes care of this for you.
 

yeatmanj

Loose Cannon
Local time
Yesterday, 22:18
Joined
Oct 11, 2000
Messages
195
The locked property only locks the field on the form. I do not know a way nor have I been able to find a way to lock a field in a table through code. Sorry, I couldn't be more help.
 

Users who are viewing this thread

Top Bottom