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?
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?
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.