Locking records

S

sonta

Hi.
Awhile back I got some useful advice in locking records using tick boxes. Eg
a field called 'Locked' was used to tick (yes/no format) any record in the
datasheet view.
But I would like to know how to do the same when a particular date field
(field name: 'File Date') is populated by the user.
Below is the example of the tick box method...wondering if anyone can modify
the method to my question. thanks.

Set the form's Allow Edits and Allow Deletions properties in the
Form_Current() event procedure.

Private Sub Form_Current()

With Me
.AllowEdits = Not Me.Locked
.AllowDeletions = .AllowEdits
End With

End Sub
 
D

Damien McBain

sonta said:
Hi.
Awhile back I got some useful advice in locking records using tick
boxes. Eg a field called 'Locked' was used to tick (yes/no format)
any record in the datasheet view.
But I would like to know how to do the same when a particular date
field (field name: 'File Date') is populated by the user.
Below is the example of the tick box method...wondering if anyone can
modify the method to my question. thanks.

Set the form's Allow Edits and Allow Deletions properties in the
Form_Current() event procedure.

Private Sub Form_Current()

With Me
.AllowEdits = Not Me.Locked
.AllowDeletions = .AllowEdits
End With

End Sub

You can create an AfterUpdate event for the "FileDate" field which does
anything you like.
I'm not entirely clear about the question, do you want to lock controls on
the form (like text boxes etc) or records in the recordset?
 
P

Pieter Wijnen

Put the code on the after_update event of the control
Sub File_Date_AfterUpdate()
With Me
.AllowEdits = IsNull(.File_Date)
.AllowDeletions = .AllowEdits
End With
End Sub

HTH
Pieter
 
V

Van T. Dinh

Use the following in *both* the Form_Current Event and Form_AfterUpdate
Event:

With Me
.AllowEdits = IsNull(.[File Date])
.AllowDeletions = .AllowEdits
End With
 
P

Pieter Wijnen

my mistake...

Pieter

Van T. Dinh said:
Use the following in *both* the Form_Current Event and Form_AfterUpdate
Event:

With Me
.AllowEdits = IsNull(.[File Date])
.AllowDeletions = .AllowEdits
End With


--
HTH
Van T. Dinh
MVP (Access)




sonta said:
Hi.
Awhile back I got some useful advice in locking records using tick
boxes.
Eg
a field called 'Locked' was used to tick (yes/no format) any record in the
datasheet view.
But I would like to know how to do the same when a particular date field
(field name: 'File Date') is populated by the user.
Below is the example of the tick box method...wondering if anyone can modify
the method to my question. thanks.

Set the form's Allow Edits and Allow Deletions properties in the
Form_Current() event procedure.

Private Sub Form_Current()

With Me
.AllowEdits = Not Me.Locked
.AllowDeletions = .AllowEdits
End With

End Sub
 
S

sonta

Thanks for the help.
If I could ask another question relating to the locking.
I'd like to create a macro button on the form where the user presses the
button to unlock the current record they are viewing (ie. to remove the date
in the 'File Date' field). Once they are finished with editing the record,
they can simply type the date in the 'File Date' field to lock the record.
P.S. could all the locked fields on the form somehow display a grey
background to visual show the user that the field is not usable.

thanks again.
 

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