Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking forms

Status
Not open for further replies.

austen

Technical User
Nov 12, 2008
14
GB
Please can someone help?
I have a database where I need to lock the forms once it has been completed and checked. I.e. I don't want it editable after this. I know nothing about code just basic forms, queries, tables etc. Can anyone help me with this please?
 
Have a look in form design at the allowupdate option.

You can turn it on and off in code.

so...

Form_OnNewRecord
me.allowupdates=true

form_afterupdate
me.allowupdates=false

This allows a new rcord to be saved, but as soon as it is, it locks again.


There are other ways - you could use command buttong to add new records and return to browsing existing ones, and use those to control the locking.

SeeThru
Synergy Connections Ltd - Telemarketing Services

 
In design view of your form, click on the little square in the upper left hand corner. When you do so, you'll see a black square inside it. That's how you select the whole form. Bring up the property sheet(button with a hand on it. It'll say properties). Click on the Event Tab. You'll see AfterUpdate. Click in the box next to it. You'll see a square with three dots (...). That's the build button. Click on it. Select Code Builder. That'll throw you into VBA. Type in: (Just the parts with Me.)
Private Sub Form_AfterUpdate()
Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End Sub

This'll lock your form and won't allow any more edits or new records.

To see what these options do, on the property sheet, click in the box next to any option and hit your F1 Key.
 

Austen, I think you need to be a little clearer about your actual intent here. You say "lock the forms once it has been completed and checked." A form is never really "completed." A record may be considered "completed" after it is saved. Is this, by chance, what you mean? If so, do you want to lock the record automatically after it is saved, or do you want to do so by ticking a checkbox after the record has been "checked" manually and deemed "complete?" Do you want to be able to add new records?


SeeThru, what version of Access includes an event named Form_OnNewRecord and a Property named AllowUpdates? Is this something new in v2007?

fneily, will not setting these properties in the Form_AfterUpdate event only persist until the form is closed then re-opened, at which time they revert to their original settings?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
missinglinq - you are right. I was assuming they meant for that one use of the form. What they could do then, as you hinted at, is to have a check indicator to show if the record is completed and, based on that, lock the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top