Lock a record

B

Brown

Is there way to lock a single record in a table?
I have a simple database with one data table. The first record in the table
is a dummy record,so that it appears when the data entry table is opened. I
want to lock this record so that the user cannot overtype it and must open a
new record.

Brown
 
A

Allen Browne

Use the Current event of the form to set its AllowEdits property, based on
the primary key value of this record.

This example assumes a primary key named "ID", and the record to lock has an
ID of 1:

Private Sub Form_Current()
Dim bLock As Boolean
If Me.[ID] = 1 Then
bLock = True
End If
If Me.AllowEdits = bLock Then
Me.AllowEdits = not bLock
Me.AllowDeletions = not bLock
End If
End Sub
 
B

Billy Yao [MSFT]

Hi Brown,

I am just checking on your progress regarding the method Allen provided you to lock the first
record. Have you tried the steps he provided to you? I wonder how the testing is going. If you
encounter any difficulty, please do not hesitate to let us know. Please post here and notify us
the status of your issue. Looking forward to hearing from you soon...

Best regards,

Billy Yao
Microsoft Online Support
 
B

Brown

Actually, I took a different tack, I set the form to open to a new record.
The documentation advises the user that the first record is a dummy,
available as an example. I'm meeting with the customer today to see if he
likes that approach.
Brown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top