Form macro

G

Guest

I have created an Access form that has 30 questions and I want to learn how
to make it so that if you answer “yes†to let’s say the first question, that
some of the other 29 questions will change shade and you won’t be able to
enter any values in those questions. Maybe this is a macro but I am not sure
how to do it…. Can you help?


Thanks Sincerely,

hadd0032
 
J

John Vinson

I have created an Access form that has 30 questions and I want to learn how
to make it so that if you answer “yes” to let’s say the first question, that
some of the other 29 questions will change shade and you won’t be able to
enter any values in those questions. Maybe this is a macro but I am not sure
how to do it…. Can you help?

I'd suggest using VBA code. Let's say you have textboxes named Q1, Q2,
.... Q30. You might have code like this in Q1's AfterUpdate event. To
edit it, open the Form in design view; view Q1's Properties; click the
.... icon by the AfterUpdate property on the Events tab, and choose
Code Builder. Access will give you the Sub and End Sub lines for free.

Private Sub Q1_AfterUpdate()
If Q1 = True Then
Q8.Enabled = False
Q11.Enabled = False
Q15.Enabled = False
End If
End Sub

You'll also want to put code in the Form's Current event to set all of
the textboxes' Enabled property to True, so when you move to a
different record they don't stay greyed out.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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