Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Acc2003 Lock controls on a Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abe Katz - 22 May 2008 16:59 GMT
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
Ryan Tisserand - 22 May 2008 17:39 GMT
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

> Hello Gentlemen!
>
[quoted text clipped - 5 lines]
> Thanks in advance
> Abe
Klatuu - 22 May 2008 19:25 GMT
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.
Signature

Dave Hargis, Microsoft Access MVP

> 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.
[quoted text clipped - 25 lines]
> > Thanks in advance
> > Abe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.