Re: Limiting the times a record can be updated



On Mon, 19 Sep 2005 12:02:02 -0700, "Sean Skallerud"
<SeanSkallerud@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>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]
.



Relevant Pages

  • RE: inputmask
    ... aan = Hour ... Update event. ... If not cancel ... Private Sub Aankomen_BeforeUpdate ...
    (microsoft.public.access.formscoding)
  • RE: GoToControl problems
    ... The after update event code occurs after the value is ... Private Sub txtDate_rcp_BeforeUpdate ... setting the focus while in a control to itself, but I am not absolutely sure. ... you can use the Cancel capability of that event to cancel the update of the ...
    (microsoft.public.access.formscoding)
  • Re: BeforeUpdate event
    ... like it to do is go to the record that is in the database. ... Private Sub SSN_BeforeUpdate ... You cannot navigate in the middle of an update event. ... Your code needs to cancel ...
    (microsoft.public.access.formscoding)
  • Re: GoToControl problems
    ... The after update event code occurs after the value is ... Private Sub txtDate_rcp_BeforeUpdate ... setting the focus while in a control to itself, but I am not absolutely sure. ... you can use the Cancel capability of that event to cancel the update of the ...
    (microsoft.public.access.formscoding)
  • Re: Dont close form on error
    ... Cancel the Before Update event if the condition is not met. ... Private Sub Form_BeforeUpdate ... Use your actual control name in place of txtSomeField, ...
    (microsoft.public.access.modulesdaovba)