Enable/disable cmd button, continuous form

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 buttons to respond, not
just that particular form-line.

My code is like:
Private Sub Testbutton_AfterUpdate()
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End Sub

I've used this on a single form, but not continuous.
any ideas? Thanks
 
K

kingston via AccessMonster.com

Use conditional formatting instead of code. Use the menu selection Tools-
Conditional Formatting... for cmdButton. Set Expression Is to [chkBox]
=False and use the last button Enabled/Disabled.
 
S

Stewart

I've looked in Access 2003 and 2002 but can't find conditional formatting
under Tools.

I searched help and found nothing conditional. I need more info, I'm
finding a lot in a Google search.

Thanks for the reply.

kingston via AccessMonster.com said:
Use conditional formatting instead of code. Use the menu selection Tools-
Conditional Formatting... for cmdButton. Set Expression Is to [chkBox]
=False and use the last button Enabled/Disabled.
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 buttons to respond, not
just that particular form-line.

My code is like:
Private Sub Testbutton_AfterUpdate()
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End Sub

I've used this on a single form, but not continuous.
any ideas? Thanks
 
K

kingston via AccessMonster.com

Sorry, that should have been the menu item Format, not Tools.
I've looked in Access 2003 and 2002 but can't find conditional formatting
under Tools.

I searched help and found nothing conditional. I need more info, I'm
finding a lot in a Google search.

Thanks for the reply.
Use conditional formatting instead of code. Use the menu selection Tools-
Conditional Formatting... for cmdButton. Set Expression Is to [chkBox] [quoted text clipped - 17 lines]
I've used this on a single form, but not continuous.
any ideas? Thanks
 
S

Stewart

I found it. Its grayed out. I try to learn more.

kingston via AccessMonster.com said:
Sorry, that should have been the menu item Format, not Tools.
I've looked in Access 2003 and 2002 but can't find conditional formatting
under Tools.

I searched help and found nothing conditional. I need more info, I'm
finding a lot in a Google search.

Thanks for the reply.
Use conditional formatting instead of code. Use the menu selection
Tools-
Conditional Formatting... for cmdButton. Set Expression Is to [chkBox]
[quoted text clipped - 17 lines]
I've used this on a single form, but not continuous.
any ideas? Thanks
 
S

Stewart

Looks like conditional formatting only works with text and combo boxes, not
check boxes or command buttons.

Stewart said:
I found it. Its grayed out. I try to learn more.

kingston via AccessMonster.com said:
Sorry, that should have been the menu item Format, not Tools.
I've looked in Access 2003 and 2002 but can't find conditional formatting
under Tools.

I searched help and found nothing conditional. I need more info, I'm
finding a lot in a Google search.

Thanks for the reply.

Use conditional formatting instead of code. Use the menu selection
Tools-
Conditional Formatting... for cmdButton. Set Expression Is to [chkBox]
[quoted text clipped - 17 lines]
I've used this on a single form, but not continuous.
any ideas? Thanks
 
K

kingston via AccessMonster.com

You're right. I apologize again. It's been a bad day for me so far.

OK, here's a method that will work. It might not look right, but it will
work. Change your procedure to Public instead of Private. Create a
procedure for the form's OnCurrent event. Call the procedure that you just
made Public: Me.Testbutton_AfterUpdate
This will run the check and enable or disable the command button every time
the focus is moved to a record. All of the buttons will be synchronized if
you use continuous forms, but the behavior of a specific button will
correspond to that particular record. Let me know if you have any problems
with this and sorry for any confusion I've caused.
Looks like conditional formatting only works with text and combo boxes, not
check boxes or command buttons.
I found it. Its grayed out. I try to learn more.
[quoted text clipped - 14 lines]
 
S

Stewart

Ok

Tried that, is this what you had in mind?

Public Sub frmTestbutton_Form_Current() 'Me. caused an error
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End If
End Sub

Changing one line's check box doesn't effect all other buttons, but it
doesn't enable that line's cmdButton either.
All cmdButtons stay disabled regarless of check box status. I have all set
to Enabled: No.


kingston via AccessMonster.com said:
You're right. I apologize again. It's been a bad day for me so far.

OK, here's a method that will work. It might not look right, but it will
work. Change your procedure to Public instead of Private. Create a
procedure for the form's OnCurrent event. Call the procedure that you just
made Public: Me.Testbutton_AfterUpdate
This will run the check and enable or disable the command button every time
the focus is moved to a record. All of the buttons will be synchronized if
you use continuous forms, but the behavior of a specific button will
correspond to that particular record. Let me know if you have any problems
with this and sorry for any confusion I've caused.
Looks like conditional formatting only works with text and combo boxes, not
check boxes or command buttons.
I found it. Its grayed out. I try to learn more.
[quoted text clipped - 14 lines]
I've used this on a single form, but not continuous.
any ideas? Thanks
 
K

kingston via AccessMonster.com

No, what I meant was to change your existing procedure to Public. Since you
know that it works, you'd only need to call it from a different event
(OnCurrent). You still need it for the original event; you're just adding it
to another event without repeating the code. You could copy and paste the
code to the OnCurrent event, but you would continue to need it for the
checkbox's AfterUpdate event.

In short:
CheckBox AfterUpdate Event enables or disables button.
Form OnCurrent Event calls the above procedure (after it is made Public).
Ok

Tried that, is this what you had in mind?

Public Sub frmTestbutton_Form_Current() 'Me. caused an error
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End If
End Sub

Changing one line's check box doesn't effect all other buttons, but it
doesn't enable that line's cmdButton either.
All cmdButtons stay disabled regarless of check box status. I have all set
to Enabled: No.
You're right. I apologize again. It's been a bad day for me so far.
[quoted text clipped - 20 lines]
Message posted via AccessMonster.com
 
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.

I never imagined such a simple form control, on a form, wouldn't be
dedicated/exclusive to that form. I have a lot to learn

Thanks all for your time

kingston via AccessMonster.com said:
No, what I meant was to change your existing procedure to Public. Since
you
know that it works, you'd only need to call it from a different event
(OnCurrent). You still need it for the original event; you're just adding
it
to another event without repeating the code. You could copy and paste the
code to the OnCurrent event, but you would continue to need it for the
checkbox's AfterUpdate event.

In short:
CheckBox AfterUpdate Event enables or disables button.
Form OnCurrent Event calls the above procedure (after it is made Public).
Ok

Tried that, is this what you had in mind?

Public Sub frmTestbutton_Form_Current() 'Me. caused an error
If Me.chkBox = True Then
Me.cmdButton.Enabled = True
Else: Me.cmdButton.Enabled = False
End If
End Sub

Changing one line's check box doesn't effect all other buttons, but it
doesn't enable that line's cmdButton either.
All cmdButtons stay disabled regarless of check box status. I have all
set
to Enabled: No.
You're right. I apologize again. It's been a bad day for me so far.
[quoted text clipped - 20 lines]
Message posted via AccessMonster.com
 

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