Acc2003 Lock controls on a Form

  • Thread starter Thread starter Abe Katz
  • Start date Start date
A

Abe Katz

Hello Gentlemen!

On my invoice form, i want to do the following. If the when invoice is paid,
I want to lock the invoice that the user should not be able to do any
changes to the invoice.
In the OnCurrent event I can find out if the invoice is paid or not.
What is the easiest way to do this?
Thanks in advance
Abe
 
I will assume that your "Invoice is Paid" is a yes/no field. Using the "On
Activate" event of the form you would use this code.

If Me!InvoiceIsPaid = True Then
Me.Form.AllowAdditions = False
Me.Form.AllowEdits = False
Me.Form.AllowDeletions =False
End If

If the "Invoice is Paid" is a text box just change this
If Me!InvoiceIsPaid = "Paid"

You can lock single controls with this code

If Me!InvoiceIsPaid = True Then
Me!FieldName.Enabled = False
End If

Hope this helps
 
The Activate event is not correct. It fires after the Load event when the
form is first opened and doesn't fire again unless you move to a different
form and back.
The form current event would be the correct event to use. Certainly you can
control controls indiviually, but the easiest way is:

With Me
If .NewRecord Then
.AllowEdits = True
ElseIf .txtInvoicePaid Then
.AllowEdits = False
Else
.AllowEdits = True
End If
End With

Or more simply:

Me.AllowEdits = Not Me.txtInvoicePaid Or Me.NewRecord

Assuming txtInvoicePaid is bound to a Yes/No field.
 

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

Back
Top