Disable and Enable command button

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

mdavis via AccessMonster.com

Form A has an unbound list box based on a query. When the list box has a
record in it I want a command button called ADD to be disabled and a command
button called EDIT to be enabled.

When their isn't a record in the list box I would like the ADD command button
to be enabled and the EDIT command button to be disabled.
 
N

NthDegree via AccessMonster.com

Would this do it for you?

Run this code from the "After Update" action of the list box.

if isnull(listbox) or listbox = "" then
cmdAdd.Enabled = True
cmdEdit.Enabled = False
else
cmdAdd.Enabled = False
cmdEdit.Enabled = True
end if

As a suggestion, I would put both command buttons on top of each other and
then in the code above substitute "Visible" for "Enabled". The way they would
only see the button that is appropriate for the situation.
 
M

mdavis via AccessMonster.com

Thank you for the quick response. It is almost working.

I forgot to mention that the ADD and EDIT command buttons open up a pop up
form to either "add" or "edit/delete" a record. Where would I put code to
move the focus from either command buttons on Form A (the main form) after I
have closed the pop up forms?

Both of the pop up forms have a SAVE and CANCEL command button.

Thanks for your help. Cool idea about stacking the command buttons on top of
each other.
 

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