MSAC2K -- Locking forms to prevent edits....

  • Thread starter Thread starter David Dubroff
  • Start date Start date
D

David Dubroff

Microsoft Access 2000 Question:

What is the best way to toggle a form for locking and unlocking the ability
to edit existing data?

Should I toggle the "AllowEdits" parameter based upon its current value? If
so, how do I accomplish this?

I am not sure how to get VBA to grab the current value of the "AllowEdits"
parameter.

Or.... should I be considering a "For....Next" loop to alter the "Enabled"
property for all controls. If so, how do I accomplish this?

What I would like to have is some object on the form that displays the
current "Lock / Unlock" status. Nearby to this status indicator should be
some way to change the form between the locked and unlocked status.

Please advise....

Dave
 
David,

To toggle allow edits yes/no, lace the following line of
code in the click event of the button:

Forms("FormName").AllowEdits = Not Forms
("FormName").AllowEdits
Forms("FormName").Controls("Label1").Caption = "Editing
allowed: " & Forms("FormName").AllowEdits

The second line will display current status in a label
(Label1) on your form (add the label).
Modify names accordingly and make sure the default label
caption corresponds to the default status on form open.

HTH,
Nikos
 
I tried the following lie of code within the OnClick of a button:

Forms("Top_Level").AllowEdits = Not Forms("Top_Level").AllowEdits

When I click the button, the form gets unlocked for edits. However, when I
click the button again, the form is not locked for edits.

The form initially opens as locked. I want to be able to have one button on
the form that switches the form between locked and unlocked for edits.

Please advise...
Dave
 
I managed to get the following code to work for toggling the form between
being locked and unlocked for edits.

If Me.AllowEdits = False Then
Me.AllowEdits = True
DoCmd.RunCommand acCmdRefresh
Exit Sub
End If
If Me.AllowEdits = True Then
Me.AllowEdits = False
DoCmd.RunCommand acCmdRefresh
Exit Sub
End If
 
David,

I'm really surprised it didn't work... it works fine for
me (A2K, W2K). Anyway, glad you solved your problem.

Best,
Nikos
 
Back
Top