Blocking a record

J

John

Hi

Is it possible to block editing of a record in a form based on a value in
the record?

Thanks

Regards
 
R

Rick Gittins

Yes, you can change the enabled property of the objects on your form.

If txt1.text = "Yes" Then
txt2.enabled=false
txt3.enabled=false
end if

Rick
 
N

Nikos Yannacopoulos

John,

All you need is some simple code in the form's On Current event. For
example, assuming there is a textbox txtStatus, and you want to not
allow editing if its value is "Completed", the code would be:

Me.AllowEdits = Not (Me.txtStatus = "Completed")

HTH,
Nikos
 
A

Allen Browne

Sure.

In the Current event of the form, set the AllowEdits property of the form
(and AllowDeletions?) depending on the value.

This example locks editing if the InvoiceDate is more than 30 days ago:

Private Sub Form_Current()
Dim bLock as Boolean

If Me.InvoiceDate < Date() - 30 Then
bLock = True
End If

Me.AllowEdits = Not bLock
End Sub
 
J

John

Oh no, there are a million fields on the form. I want to do this before my
retirement. :)

thanks

regards
 
J

Joseph Meehan

John said:
Hi

Is it possible to block editing of a record in a form based on a
value in the record?

Thanks

Regards

Yes, you can use a value in the record to set the properties of the form
to not allow edits. Note that anyone who would want to could still go to
the table or change the form or other methods to change the value if they
wished.
 
J

Joseph Meehan

John said:
Hi

Is it possible to block editing of a record in a form based on a
value in the record?

Thanks

Regards

I have not done it, but I see no reason it could be be blocked. You
would need to write a little VBA code to do it.
 
Top