Results 1 to 6 of 6
  1. #1
    alobo is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    4

    Make questions appear on form based on answer to previous question

    Hi All

    I am new to Access and I am a bit confused. I am trying to make a form to fill in data with. Some of the questions are yes/no to which there are follow up questions if answered yes. I want those follow up questions to be disabled unless the previous question is check marked yes. How do I do this? (Also, I want to be able to see the question just not input any values. Also, I am working with access 2003.

    Also, I have already put in the yes/no questions on the form, but I cannot seem to click on the conditional formatting... I have no idea if I am doing this right....

    PLEASE HELP!



    Thanks

    anj

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    It doesn't have anything to do with conditional formatting. The property you want is "Enabled" When that property for a control is True, then the user can interact with that control. If it is False, then the user cannot.

    So, you will start off with those controls being set Enabled = False. You can set them all in the Form's load event, or set them in the Form design. I would tend to use the load, and I've forgotten why. Probably because it's obvious in the module when you're editing the control code.

    Anyway, suppose that questions 2 and 3 will only be enabled when question 1 is answered "Yes". Suppose that Question 1 uses a checkbox called chkQuest1. Suppose that Question 2 is a text Box called txtQuest2, and Question 3 is a combo Box called cboQuest3. In the OnCheck or the AfterUpdate event of chkQuest1, you would put code that changes the Enabled property of the other two controls:
    Code:
    sub chkQuest1_AfterUpdate()
       if chkQuest1 Then
          txtQuest2.Enabled = True
          cboQuest3.Enabled = True
       Else 
          txtQuest2.Enabled = False
          cboQuest3.Enabled = False
       End If
    End Sub
    Or even, since a checkbox has a true/false value, just
    Code:
    sub chkQuest1_AfterUpdate()
        txtQuest2.Enabled = chkQuest1
        cboQuest3.Enabled = chkQuest1
    End Sub
    Then you just have to make sure to set those back to Enabled = False when you go to a new record or refresh the form.

  3. #3
    alobo is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    4
    Hi!

    Thanks for your reply. Couple of questions.

    1. Where is the Form's load event?
    2. How do I know what the checkboxes are called?
    3. Do I insert the code after clicking the icon that says code?

    Sorry, I am computer illiterate, and this is for work!! :S

    Thanks again

    anj


    Quote Originally Posted by Dal Jeanis View Post
    It doesn't have anything to do with conditional formatting. The property you want is "Enabled" When that property for a control is True, then the user can interact with that control. If it is False, then the user cannot.

    So, you will start off with those controls being set Enabled = False. You can set them all in the Form's load event, or set them in the Form design. I would tend to use the load, and I've forgotten why. Probably because it's obvious in the module when you're editing the control code.

    Anyway, suppose that questions 2 and 3 will only be enabled when question 1 is answered "Yes". Suppose that Question 1 uses a checkbox called chkQuest1. Suppose that Question 2 is a text Box called txtQuest2, and Question 3 is a combo Box called cboQuest3. In the OnCheck or the AfterUpdate event of chkQuest1, you would put code that changes the Enabled property of the other two controls:
    Code:
    sub chkQuest1_AfterUpdate()
       if chkQuest1 Then
          txtQuest2.Enabled = True
          cboQuest3.Enabled = True
       Else 
          txtQuest2.Enabled = False
          cboQuest3.Enabled = False
       End If
    End Sub
    Or even, since a checkbox has a true/false value, just
    Code:
    sub chkQuest1_AfterUpdate()
        txtQuest2.Enabled = chkQuest1
        cboQuest3.Enabled = chkQuest1
    End Sub
    Then you just have to make sure to set those back to Enabled = False when you go to a new record or refresh the form.

  4. #4
    alobo is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    4
    I wonder if I can upload the file if you might be able to help me. Its only a couple of points (like 4-5). please let me know. thanks!

  5. #5
    alobo is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    4
    Never-mind!!! I figured it out!!! NOT COMPLETELY COMPUTER ILLITERATE!!! WOOT!!!

  6. #6
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Congratulations! We were all there once.

    Please mark the thread solved. Top of page, under Thread Tools. If you come up with any other questions, please start a new thread.

    I'm going to answer your post #3 questions anyway, just in case anyone reads this thread and needs to know.

    1) Click the Form, then open the properties pane. Click the Events tab. click in the box next to the Load event. Click the three dots. Select Code Builder. Put the code there.

    2) Click on the check-box (or any other control). If the properties pane isn't open, right-click the control and select the properties pane. At the top of the pane, it should tell you the Selection Type: Checkbox and a dropdown box with the name of the checkbox. If there's any doubt, you can click the "All" tab in the Porperties Pane, and the top field should be "Name".

    3) Yes.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-28-2013, 11:48 AM
  2. Replies: 3
    Last Post: 07-08-2011, 05:48 AM
  3. Make new field based on previous field's answer
    By VictoriaAlbert in forum Access
    Replies: 1
    Last Post: 04-11-2011, 09:54 PM
  4. Review/new answer to a question sub-form
    By vt800c in forum Forms
    Replies: 0
    Last Post: 10-18-2010, 12:04 PM
  5. Replies: 2
    Last Post: 11-17-2006, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums