Greying out fields

  • Follow


Can Access grey out fields on a form depending on whether or not a tick box 
is ticked? And if it can how do I do it?!
0
Reply Utf 1/10/2008 9:18:00 AM

In the AfterUpdate event of the checkbox, put code like:

Private Sub Check0_AfterUpdate()

  Me.Text1.Enabled = Not Me.Check0

End Sub

That will gray out (disable) the field when the check box is checked, and 
enable it when the check box is unchecked.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Sel" <Sel@discussions.microsoft.com> wrote in message 
news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
> Can Access grey out fields on a form depending on whether or not a tick 
> box
> is ticked? And if it can how do I do it?! 


0
Reply Douglas 1/10/2008 11:25:35 AM


Thankyou, I've got it to work for one text box. Is it possible to disable 
multiple fields (text boxes and drop-downs) by checking one check box?

"Douglas J. Steele" wrote:

> In the AfterUpdate event of the checkbox, put code like:
> 
> Private Sub Check0_AfterUpdate()
> 
>   Me.Text1.Enabled = Not Me.Check0
> 
> End Sub
> 
> That will gray out (disable) the field when the check box is checked, and 
> enable it when the check box is unchecked.
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Sel" <Sel@discussions.microsoft.com> wrote in message 
> news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
> > Can Access grey out fields on a form depending on whether or not a tick 
> > box
> > is ticked? And if it can how do I do it?! 
> 
> 
> 
0
Reply Utf 1/10/2008 12:49:00 PM

Sure. And, in fact, you can do different things for different controls. For 
instance, if you want a check in Check0 to disable Text1 and Text2, and 
enable Text 3 (or no check in Check0 to enable Text1 and Text2 and disable 
Text3), you'd use

Private Sub Check0_AfterUpdate()

  Me.Text1.Enabled = Not Me.Check0
  Me.Text2.Enabled = Not Me.Check0
  Me.Text3.Enabled = Me.Check0

End Sub


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Sel" <Sel@discussions.microsoft.com> wrote in message 
news:05C79D04-95D4-4A5F-95F5-7E6208A394D8@microsoft.com...
> Thankyou, I've got it to work for one text box. Is it possible to disable
> multiple fields (text boxes and drop-downs) by checking one check box?
>
> "Douglas J. Steele" wrote:
>
>> In the AfterUpdate event of the checkbox, put code like:
>>
>> Private Sub Check0_AfterUpdate()
>>
>>   Me.Text1.Enabled = Not Me.Check0
>>
>> End Sub
>>
>> That will gray out (disable) the field when the check box is checked, and
>> enable it when the check box is unchecked.
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Sel" <Sel@discussions.microsoft.com> wrote in message
>> news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
>> > Can Access grey out fields on a form depending on whether or not a tick
>> > box
>> > is ticked? And if it can how do I do it?!
>>
>>
>> 


0
Reply Douglas 1/10/2008 1:06:54 PM

Thanks, I tried that and the first time instead of disabling both Text 1 and 
Text 2 it disabled Text 1 and cleared the information from Text 2! I've now 
retried and now I can't get it to disable anything at all! Even when I 
recreate a brand new form and try it on that it still won't work!

Is there some sort of option I may have pressed that has stopped this from 
working?

"Douglas J. Steele" wrote:

> Sure. And, in fact, you can do different things for different controls. For 
> instance, if you want a check in Check0 to disable Text1 and Text2, and 
> enable Text 3 (or no check in Check0 to enable Text1 and Text2 and disable 
> Text3), you'd use
> 
> Private Sub Check0_AfterUpdate()
> 
>   Me.Text1.Enabled = Not Me.Check0
>   Me.Text2.Enabled = Not Me.Check0
>   Me.Text3.Enabled = Me.Check0
> 
> End Sub
> 
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Sel" <Sel@discussions.microsoft.com> wrote in message 
> news:05C79D04-95D4-4A5F-95F5-7E6208A394D8@microsoft.com...
> > Thankyou, I've got it to work for one text box. Is it possible to disable
> > multiple fields (text boxes and drop-downs) by checking one check box?
> >
> > "Douglas J. Steele" wrote:
> >
> >> In the AfterUpdate event of the checkbox, put code like:
> >>
> >> Private Sub Check0_AfterUpdate()
> >>
> >>   Me.Text1.Enabled = Not Me.Check0
> >>
> >> End Sub
> >>
> >> That will gray out (disable) the field when the check box is checked, and
> >> enable it when the check box is unchecked.
> >>
> >> -- 
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Sel" <Sel@discussions.microsoft.com> wrote in message
> >> news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
> >> > Can Access grey out fields on a form depending on whether or not a tick
> >> > box
> >> > is ticked? And if it can how do I do it?!
> >>
> >>
> >> 
> 
> 
> 
0
Reply Utf 1/10/2008 2:35:03 PM

What's the exact code you've got? (copy-and-paste, rather than retype)

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Sel" <Sel@discussions.microsoft.com> wrote in message 
news:031F1694-6128-4566-B5AD-660C1B3C36B4@microsoft.com...
> Thanks, I tried that and the first time instead of disabling both Text 1 
> and
> Text 2 it disabled Text 1 and cleared the information from Text 2! I've 
> now
> retried and now I can't get it to disable anything at all! Even when I
> recreate a brand new form and try it on that it still won't work!
>
> Is there some sort of option I may have pressed that has stopped this from
> working?
>
> "Douglas J. Steele" wrote:
>
>> Sure. And, in fact, you can do different things for different controls. 
>> For
>> instance, if you want a check in Check0 to disable Text1 and Text2, and
>> enable Text 3 (or no check in Check0 to enable Text1 and Text2 and 
>> disable
>> Text3), you'd use
>>
>> Private Sub Check0_AfterUpdate()
>>
>>   Me.Text1.Enabled = Not Me.Check0
>>   Me.Text2.Enabled = Not Me.Check0
>>   Me.Text3.Enabled = Me.Check0
>>
>> End Sub
>>
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Sel" <Sel@discussions.microsoft.com> wrote in message
>> news:05C79D04-95D4-4A5F-95F5-7E6208A394D8@microsoft.com...
>> > Thankyou, I've got it to work for one text box. Is it possible to 
>> > disable
>> > multiple fields (text boxes and drop-downs) by checking one check box?
>> >
>> > "Douglas J. Steele" wrote:
>> >
>> >> In the AfterUpdate event of the checkbox, put code like:
>> >>
>> >> Private Sub Check0_AfterUpdate()
>> >>
>> >>   Me.Text1.Enabled = Not Me.Check0
>> >>
>> >> End Sub
>> >>
>> >> That will gray out (disable) the field when the check box is checked, 
>> >> and
>> >> enable it when the check box is unchecked.
>> >>
>> >> -- 
>> >> Doug Steele, Microsoft Access MVP
>> >> http://I.Am/DougSteele
>> >> (no e-mails, please!)
>> >>
>> >>
>> >> "Sel" <Sel@discussions.microsoft.com> wrote in message
>> >> news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
>> >> > Can Access grey out fields on a form depending on whether or not a 
>> >> > tick
>> >> > box
>> >> > is ticked? And if it can how do I do it?!
>> >>
>> >>
>> >>
>>
>>
>> 


0
Reply Douglas 1/10/2008 4:12:20 PM

Aah, it's ok now! Someones just pointed out to me that I'd got them the wrong 
way round. Thankyou very much for your help - it's much appreciated!

Sel

"Douglas J. Steele" wrote:

> What's the exact code you've got? (copy-and-paste, rather than retype)
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Sel" <Sel@discussions.microsoft.com> wrote in message 
> news:031F1694-6128-4566-B5AD-660C1B3C36B4@microsoft.com...
> > Thanks, I tried that and the first time instead of disabling both Text 1 
> > and
> > Text 2 it disabled Text 1 and cleared the information from Text 2! I've 
> > now
> > retried and now I can't get it to disable anything at all! Even when I
> > recreate a brand new form and try it on that it still won't work!
> >
> > Is there some sort of option I may have pressed that has stopped this from
> > working?
> >
> > "Douglas J. Steele" wrote:
> >
> >> Sure. And, in fact, you can do different things for different controls. 
> >> For
> >> instance, if you want a check in Check0 to disable Text1 and Text2, and
> >> enable Text 3 (or no check in Check0 to enable Text1 and Text2 and 
> >> disable
> >> Text3), you'd use
> >>
> >> Private Sub Check0_AfterUpdate()
> >>
> >>   Me.Text1.Enabled = Not Me.Check0
> >>   Me.Text2.Enabled = Not Me.Check0
> >>   Me.Text3.Enabled = Me.Check0
> >>
> >> End Sub
> >>
> >>
> >> -- 
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Sel" <Sel@discussions.microsoft.com> wrote in message
> >> news:05C79D04-95D4-4A5F-95F5-7E6208A394D8@microsoft.com...
> >> > Thankyou, I've got it to work for one text box. Is it possible to 
> >> > disable
> >> > multiple fields (text boxes and drop-downs) by checking one check box?
> >> >
> >> > "Douglas J. Steele" wrote:
> >> >
> >> >> In the AfterUpdate event of the checkbox, put code like:
> >> >>
> >> >> Private Sub Check0_AfterUpdate()
> >> >>
> >> >>   Me.Text1.Enabled = Not Me.Check0
> >> >>
> >> >> End Sub
> >> >>
> >> >> That will gray out (disable) the field when the check box is checked, 
> >> >> and
> >> >> enable it when the check box is unchecked.
> >> >>
> >> >> -- 
> >> >> Doug Steele, Microsoft Access MVP
> >> >> http://I.Am/DougSteele
> >> >> (no e-mails, please!)
> >> >>
> >> >>
> >> >> "Sel" <Sel@discussions.microsoft.com> wrote in message
> >> >> news:A8228921-D4A4-410C-A3E5-754967038C41@microsoft.com...
> >> >> > Can Access grey out fields on a form depending on whether or not a 
> >> >> > tick
> >> >> > box
> >> >> > is ticked? And if it can how do I do it?!
> >> >>
> >> >>
> >> >>
> >>
> >>
> >> 
> 
> 
> 
0
Reply Utf 1/10/2008 4:20:01 PM

6 Replies
498 Views

(page loaded in 0.05 seconds)


Reply: