How do I grey out a button on my form?

  • Follow


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?
0
Reply Utf 2/25/2010 9:14:01 PM

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


0
Reply ghetto_banjo 2/25/2010 9:57:42 PM


In which object property do I insert this code?

"ghetto_banjo" wrote:

> 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
> 
> 
> .
> 
0
Reply Utf 2/26/2010 2:42:01 AM

On Thu, 25 Feb 2010 18:42:01 -0800, gagecres
<gagecres@discussions.microsoft.com> wrote:

>In which object property do I insert this code?
>
>"ghetto_banjo" wrote:
>
>> 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
>> 
>> 
>> .
>> 

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.
-- 

             John W. Vinson [MVP]
0
Reply John 2/26/2010 6:10:30 AM

Thanks to you both.  This worked perfectly.

"John W. Vinson" wrote:

> On Thu, 25 Feb 2010 18:42:01 -0800, gagecres
> <gagecres@discussions.microsoft.com> wrote:
> 
> >In which object property do I insert this code?
> >
> >"ghetto_banjo" wrote:
> >
> >> 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
> >> 
> >> 
> >> .
> >> 
> 
> 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.
> -- 
> 
>              John W. Vinson [MVP]
> .
> 
0
Reply Utf 2/26/2010 2:31:02 PM

4 Replies
1242 Views

(page loaded in 0.053 seconds)

Similiar Articles:













8/1/2012 1:53:02 PM


Reply: