Enable Fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form where i have made all fields Locked and have set enabled to No.
So that staff can only search clients and view there data, without
mistakenly changing anything. What i want to Do is have a command button at
the botton Name "edit" and if people wish to make a change they click edit.
Upon clicking the button all the fields change to enalbled and Unlocked so
they can be changed.

I also wish to have a save button that will lock all the fields again and
change the enabled back to no when they save it.

Can Someone help me out.

Thanks

Andrew
 
It's a lot easier to just use the Allow Edits property of the form,
rather than writing code to change the appearance of all the controls.

You could also put a label on the form which is made visible/invisible,
or has the caption changed, by the Edit / Save buttons, so user know
which "mode" they are in.

John
 
Thanks

I have a Search text box and a list box that staff are allowed access to in
order to find the client. If i use the allow edits will they still be
allowed to access these.
 
Ah, a wrinkle you didn't mention.

No, if the form does not allow edits they can't change anything, even
unbound controls.

Using VBA, you can quite easily go through the controls collection of
the form, and make them locked/unlocked as required, remembering not to
touch the command buttons:

dim ctl as control

for each ctl in me.controls
if ctl.name <> "button1" and ctl.name <> "button2" and
ctl.controltype <> aclabel then
... whatever changes you need to make
endif

next

Something like that. Remember not all properties apply to every type of
control.

John
 
Back
Top