Greying out fields

S

Sel

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?!
 
D

Douglas J. Steele

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

Sel

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?
 
D

Douglas J. Steele

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
 
S

Sel

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?
 
S

Sel

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
 

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