How do I grey out a button on my form?

G

gagecres

I'd like to grey out a button on my form if there are no records saved in the
database. Is there a way to do this?
 
G

ghetto_banjo

to make a command button "greyed out", or disabled, you can do it in
VB like:

me.buttonname.enabled = False



If you want to check if a table has no records you could do:

if DCount("*", "myTable") = 0 then
me.buttonname.enabled = False
Else
me.buttonname.enabled = True
end if
 
J

John W. Vinson

In which object property do I insert this code?

The form's Current event property (it should say [Event Procedure] and you
would enter this code, appropriately edited, by clicking the ... icon and
choosing Code Builder).

If an entry in some other control should disable the button, put the same code
in the AfterUpdate event of that control as well.
 
G

gagecres

Thanks to you both. This worked perfectly.

John W. Vinson said:
In which object property do I insert this code?

The form's Current event property (it should say [Event Procedure] and you
would enter this code, appropriately edited, by clicking the ... icon and
choosing Code Builder).

If an entry in some other control should disable the button, put the same code
in the AfterUpdate event of that control as well.
 

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