Limiting the times a record can be updated

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my dilemma, I need a user to be allowed to edit a record, but they
will only be able to edit said record one time.

They will be doing this in a continous form based off a query (which is
based off of 3 tables). There will be between 5 and 20 records that will be
displayed on the form at any given time (for the number of people that report
to that supervisor). We do not want any of the records being updated more
than one time.

How would I go about doing this? Thanks in advance for any help that is
offered.
 
Here is my dilemma, I need a user to be allowed to edit a record, but they
will only be able to edit said record one time.

They will be doing this in a continous form based off a query (which is
based off of 3 tables). There will be between 5 and 20 records that will be
displayed on the form at any given time (for the number of people that report
to that supervisor). We do not want any of the records being updated more
than one time.

How would I go about doing this? Thanks in advance for any help that is
offered.

You would need to have an additional field in the Table to indicate
that the record has been updated. I'd use a Yes/No field,
HasBeenUpdated, and set it to False by default, and to True in the
Form's AfterUpdate event.

In the form's Before update event, check the value of HasBeenUpdated
and cancel the update if it's true:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!HasBeenUpdated Then
Cancel = True
MsgBox "You already updated this once. Sorry; you had your chance!"
End If
End Sub

John W. Vinson[MVP]
 
set it to True in the Form's AfterUpdate event.

John, didn't you mean to say the BeforeUpdate event?? (if not, how does the
value get saved since the 2nd BeforeUpdate will cancel itself?)

Anyway, another possible approach (same idea though but might make use of
existing data structure) would be to add a AddedOn and ChangedOn field in
your table. Required = True. The default value of both of these fields
(filled in when the record is created) = Now(). In the Before Update event,
if the 2 values are the same, allow the update and change the ChangedOn
value to Now(). If the values are different (which could only happen if the
record has been updated once), Cancel the Update and tell the user why.

HTH,
--
George Nicholson

Remove 'Junk' from return address.
 
John, didn't you mean to say the BeforeUpdate event?? (if not, how does the
value get saved since the 2nd BeforeUpdate will cancel itself?)

Quite right! Mental lapse there - I was thinking of a Control's
AfterUpdate, rather than a Form's. BeforeUpdate it is (and I like your
Datefield idea even better).

John W. Vinson[MVP]
 
Back
Top