Locking records

G

Guest

Hi!

I have a form for orders and a subform for order details. After invoicing a
checkbox turns to "Yes" which means the order has invoiced. I have done a
code to lock records non editable. It works on the main form perfectly but on
the subform not. The code is following:

Private Sub Form_Current()
If Invoiced = True Then
Me.AllowEdits = False
Else
AllowEdits = True
End If
End Sub

I have tried that code with the subform various events but allways I can
edit records on the subform although not on the main form. What kind of
procedure is needed for the subform to lock records like the main form?
 
A

Allen Browne

Why not set the AllowEdits property of the form in the subform as well?

Presumably you want to block deletions as well as edits if it is invoiced,
so something like this:

Private Sub Form_Current()
Dim bLock As Boolean

bLock = Nz(Me.Invoiced, False)

If Me.AllowEdits <> bLock Then
Me.AllowEdits = bLock
Me.AllowDeletions = bLowk
With Me.[Sub1].Form
.AllowEdits = bLock
.AllowDeletions = bLock
End With
End If
End Sub
 

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