Disable Command Button

  • Thread starter Thread starter mdavis via AccessMonster.com
  • Start date Start date
M

mdavis via AccessMonster.com

I would like to click a command button called "Save" on Form "A" and as Form
"A" closes and returns me to Form "B" I would like to make a command button
on Form "B" to be disabled.

Thank you in advance.
 
I would like to click a command button called "Save" on Form "A" and as Form
"A" closes and returns me to Form "B" I would like to make a command button
on Form "B" to be disabled.

Thank you in advance.

What do you mean by 'and returns me to Form "B"?
Is Form B opened by Form A?

In the Command Button Save click event:

' Place your current Save code here.
DoCmd.OpenForm "FormB"
forms!FormB!CommandButtonName.Enabled = False
 
Sorry I did not give the proper info.
Form B is the main form and is already opened. The user clicks a command
button called ADD (on Form B) that takes them to a pop up form (Form A).
Then if the user clicks the SAVE command button I want the ADD command button
to be disabled on Form B.

I added the code you gave me but I get an error that says "You can't disable
a control while it has the focus". Do you know what the code would be to fix
this?

Thanks for all your help.
 
Sorry I did not give the proper info.
Form B is the main form and is already opened. The user clicks a command
button called ADD (on Form B) that takes them to a pop up form (Form A).
Then if the user clicks the SAVE command button I want the ADD command button
to be disabled on Form B.

I added the code you gave me but I get an error that says "You can't disable
a control while it has the focus". Do you know what the code would be to fix
this?

Thanks for all your help.

Sure.
Forms!FormB!AnyOtherControl.SetFocus
Forms!FormB!CommandButton.Enabled = False
 
Works like a charm. Thanks again.
Sorry I did not give the proper info.
Form B is the main form and is already opened. The user clicks a command
[quoted text clipped - 22 lines]
Sure.
Forms!FormB!AnyOtherControl.SetFocus
Forms!FormB!CommandButton.Enabled = False
 
One more thing. When I close Form B and reopen it the command button is
enabled.
I would like the command button to be disabled as long as Combo Box B has a
value in it. If there isn't a value in the Combo Box than I would like the
Command Button to be enabled.
Could you please help me with the code for this?

Thank you.


Sorry I did not give the proper info.
Form B is the main form and is already opened. The user clicks a command
[quoted text clipped - 22 lines]
Sure.
Forms!FormB!AnyOtherControl.SetFocus
Forms!FormB!CommandButton.Enabled = False
 
One more thing. When I close Form B and reopen it the command button is
enabled.
I would like the command button to be disabled as long as Combo Box B has a
value in it. If there isn't a value in the Combo Box than I would like the
Command Button to be enabled.
Could you please help me with the code for this?

Thank you.


Sorry I did not give the proper info.
Form B is the main form and is already opened. The user clicks a command
[quoted text clipped - 22 lines]
DoCmd.OpenForm "FormB"
forms!FormB!CommandButtonName.Enabled = False

Sure.
Forms!FormB!AnyOtherControl.SetFocus
Forms!FormB!CommandButton.Enabled = False

Code the Form's Current event:
Me!CommandButtonName.Enabled = Not IsNull(ComboB)

in which case there will most likely be no need to set it from FormA.
 
This works great.
But now if I delete the record that is in COMBO B how do I make the COMMAND
BUTTON enabled so that I can enter another record?
One more thing. When I close Form B and reopen it the command button is
enabled.
[quoted text clipped - 16 lines]
Code the Form's Current event:
Me!CommandButtonName.Enabled = Not IsNull(ComboB)

in which case there will most likely be no need to set it from FormA.
 
This works great.
But now if I delete the record that is in COMBO B how do I make the COMMAND
BUTTON enabled so that I can enter another record?
One more thing. When I close Form B and reopen it the command button is
enabled.
[quoted text clipped - 16 lines]
Forms!FormB!AnyOtherControl.SetFocus
Forms!FormB!CommandButton.Enabled = False

Code the Form's Current event:
Me!CommandButtonName.Enabled = Not IsNull(ComboB)

in which case there will most likely be no need to set it from FormA.

Place the same code in the ComboB AfterUpdate event.
 
The COMMAND BUTTON stays disabled? I can't seem to get it to be enabled
after I delete the record.

I probably should've mentioned that the control that you are referring to as
"Combo B" is actually an unbound List Box. In order to edit or delete the
record in the List Box I click on an EDIT COMMAND BUTTON which opens up
another form for me to edit the record or click on a DELETE COMMAND BUTTON to
delete the record.

Should I be placing the code somewhere else instead of the LIST BOX?

I apologize for not supplying you with all of the info. I was trying to keep
it as simple as possible.
This works great.
But now if I delete the record that is in COMBO B how do I make the COMMAND
[quoted text clipped - 10 lines]
Place the same code in the ComboB AfterUpdate event.
 
Does anyone know the code I should add to make this work?

Thanks in advance.
The COMMAND BUTTON stays disabled? I can't seem to get it to be enabled
after I delete the record.

I probably should've mentioned that the control that you are referring to as
"Combo B" is actually an unbound List Box. In order to edit or delete the
record in the List Box I click on an EDIT COMMAND BUTTON which opens up
another form for me to edit the record or click on a DELETE COMMAND BUTTON to
delete the record.

Should I be placing the code somewhere else instead of the LIST BOX?

I apologize for not supplying you with all of the info. I was trying to keep
it as simple as possible.
[quoted text clipped - 3 lines]
Place the same code in the ComboB AfterUpdate event.
 
Back
Top