Enabling/disabling forms...

Nightowl4933

Tryin' to do it right...
Local time
Today, 12:07
Joined
Apr 27, 2016
Messages
151
I'm using a form to allow users to enter new records and view existing ones.

The existing forms occasionally need to be edited, but I'd rather use an Edit command button to enable the fields and therefore allow changes to be made, rather than leave them editable 'by accident'.

Initially, I set all the fields to 'locked' and then an 'On Click' expression to unlock them all. I was then going to use a command button the 'Save' the changes, but really only locking them again.

I using the On Click event procedure as follows:

With Me.
.Location.Enabled = True
.Address.Enabled = True
etc...
End With

...but it didn't work :-(

Any ideas, please?

Thanks
 
build the routine below and turn them on or off
EnableBtns false

Code:
 sub EnableBtns (pbOn as Boolean)
   txtBox1.locked= pbON
   txtBox2.locked= pbOn
   cboBox.locked= pbOn
 end sub
 
enabled is the wrong property - if a control is enabled (i.e. true as you have set) then subject to the locked property the user can edit the record, which is why it didn't work - you need to set it to false, or use the locked property per Ranmans suggestion.

Note that you are setting the control property, so all rows will be affected - including the 'new' row. This won't matter if the form is single view, but will for datasheet or continuous forms - in which case you need to use conditional formatting - where you can set the enabled property, but not the locked property.
 
Hi guys,

Thanks for your suggestions, but I'm in need of a bit more detail...

I get (most of) what you're saying, Ranman, but I'm not sure how I'd use the 'EnableBtns' in relation to the actual command buttons. Am I correct in understanding I would need to use the 'On Click' event on the Edit button to run EnableBtns (and therefore allow users to edit the fields) and then 'On Click' event on the Save Button to 'protect' the fields?

Thanks.
 
Thanks for the advice. I'll go and see what I can do with it.

Pete
 

Users who are viewing this thread

Back
Top Bottom