Control disable/enable question

S

Stewart

I'm trying to enable/disable a command button, based on a check box(table
field), on a continuous form.
This form is a one-liner with only 6 items.

The weird thing is, if say 8 records(line items) are shown, changing the
check box on any one of the line items causes all other line's buttons to
respond, not
just that particular line I'm editing.

The code I've tried is:
Private Sub Testbutton_AfterUpdate()
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End Sub

I've used this in a single forms successfully, but not continuous.
any ideas? using access 2003. Thanks
 
J

John W. Vinson

I'm trying to enable/disable a command button, based on a check box(table
field), on a continuous form.
This form is a one-liner with only 6 items.

The weird thing is, if say 8 records(line items) are shown, changing the
check box on any one of the line items causes all other line's buttons to
respond, not
just that particular line I'm editing.

The code I've tried is:
Private Sub Testbutton_AfterUpdate()
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End Sub

I've used this in a single forms successfully, but not continuous.
any ideas? using access 2003. Thanks

The problem is that a Continuous Form *appears* to have multiple controls one
above the other. It really doesn't! There's only ONE testbutton, displayed
many times. If you change that control's Properties you change all the
instances of the control.

The getaround (in A2002 and later) is to use "Conditional Formatting". Select
the command button in form design view, and select Format... Conditional
Formatting. Put an appropriate condition (e.g. chkBox = True) and select the
"Enabled" tool appropriately.

John W. Vinson [MVP]
 
C

Carl Rapson

Unfortunately, with continuous forms disabling an unbound control disables
it on every line. I don't know of any way around it except to re-think your
logic. Perhaps you could leave the button enabled but look at the value of
the checkbox in the Click event and decide what to do there.

Carl Rapson
 
J

John W. Vinson

Unfortunately, with continuous forms disabling an unbound control disables
it on every line. I don't know of any way around it except to re-think your
logic. Perhaps you could leave the button enabled but look at the value of
the checkbox in the Click event and decide what to do there.

It took me a while to realize it, but one of the most useful options of the
very useful Conditional Format feature (in A2002 and later) is in fact the
ability to selectively Enable or Disable controls on individual rows.

John W. Vinson [MVP]
 
S

Stewart

When I attempted the conditional format earlier, it was grayed out when I
have a cmdButton or check box selected. Its enabled when I select a text or
combo box first....
 
S

Stewart

I was beaten.
I just left the cmdButton enabled, and found that pressing it on the desired
row would take that specific record's info to another form to do stuff, as
was suggested.

Thanks all for your time.
 

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