format fields with a button

G

Guest

I've found some code here that allows me to lock & unlock forms with a button
- that part works great, but I'd like to change the format of the fields so
it's obvious which state it's in. i.e., greyed-out for locked. Can I add
something to this code (from Allen Browne originally, thanks allen!) to do
that?

Private Sub cmdLock_Click()
Me.Refresh
Dim bAllow As Boolean
bAllow = Not Me.AllowEdits
Me.AllowEdits = bAllow
Me.AllowAdditions = bAllow
Me.AllowDeletions = bAllow
Me.cmdLock.Caption = IIf(bAllow, "&Lock", "Un&Lock")
End Sub

I'm new to VBA but I can paste & clip with the best of them. So far so good.
Thanks,
Seana
 
A

Allen Browne

Not simple. You would need to set the Enabled property of the controls, or
meddle with the ForeColor and BackColor properties.

How about adding a transparent rectangle with (say) a red border, and size
it so it fits around the edge of the Detail section of your form? Make it
Visible when locked, and not visible with unlocked. It's a pretty good
visual clue for the user. That way you have just one more line of code to
add:
Me.rctLock.Visible = Not bAllow
where "rctLock" is the name of the red rectangle.

There's a screenshot of the concept here:
http://allenbrowne.com/ser-56.html
(though the article is describing a more advanced solution for this issue.)
 
G

Guest

(I don't think I ever responded to you).
Just wanted to say thanks. this works like a charm.

certainly beats launching an exact duplicate of a locked form on top of
itself with the controls enabled & colored differently (which was my Plan B).

seana
 

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

Top