Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2009
    Posts
    22

    Unanswered: response checking issue

    I’m building a database that contains many questionnaires for subjects to complete. When the subjects are finished with each questionnaire I make sure that they have answered every question before going on to the next one. If a question is not answered the input area is highlighted in red. See below. This function works well for us.

    The issue I have is with one form that has some optional questions. It is laid out like this:

    Question (label)............Cause Distress? (opg).......How much distress? (opg)
    1. Work environment......Yes/No..........................1,2,3,4
    2. Family.....................Yes/No..........................1,2,3,4
    3. Finances .................Yes/No..........................1,2,3,4
    …
    20. Housing .................Yes/No..........................1,2,3,4

    So if they select the “No” button they should not be required (or even able) to select one of the distress buttons. Any thoughts on how to do this?

    Thanks!


    ….
    Public Function checkResponses(sFormName As String) As Boolean

    Dim ctl As Control

    For Each ctl In Forms(sFormName).Controls
    Select Case ctl.ControlType
    Case acOptionGroup, acComboBox, acTextBox
    If IsNull(ctl.Value) Then
    ctl.BackStyle = 1
    ctl.BackColor = 6773995
    ctl.BorderColor = 6773995
    checkResponses = True
    End If
    End Select
    Next ctl

    End Function

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    What are the controls that you use on the form? What type, names, etc...
    Me.Geek = True

  3. #3
    Join Date
    Feb 2009
    Posts
    22
    Quote Originally Posted by nckdryr
    What are the controls that you use on the form? What type, names, etc...
    They are all option groups. Their names are opgQ1a/opgQ1b for the Yes/No and the Distress question respectfully. They go up to opgQ20a/opgQ20b.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Table strucutre? Screenshot?

    Is this a continuous form or a singleform with duplicated controls?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Feb 2009
    Posts
    22
    This is a single form with many controls. I'm not sure what you mean by "duplicate" controls. There is a screen shot attached of the table and the form (the form only goes up to question 9 right now but there will eventually be 20). Thanks.
    Attached Files Attached Files

  6. #6
    Join Date
    May 2005
    Posts
    1,191
    How about just a check on the OnClick event of the first option group to check if it's no, then disable/enable the second control respectively. Something like (untested):

    Code:
    if opgQ1a = 2 then  'the 'no' option
        opgQ1b.enabled = false
    else
        opgQ1b.enabled = true
    endif
    Me.Geek = True

  7. #7
    Join Date
    Feb 2009
    Posts
    22
    Quote Originally Posted by nckdryr
    How about just a check on the OnClick event of the first option group to check if it's no, then disable/enable the second control respectively. Something like (untested):

    Code:
    if opgQ1a = 2 then  'the 'no' option
        opgQ1b.enabled = false
    else
        opgQ1b.enabled = true
    endif
    I tried this but the response function still evaluates opgQ1b as being null. Even though it does not mark it red, it still throws a flag indicating there is a problem and does not allow the user to continue. But that got me thinking that I could add something to the response function that ignores any controls that are disabled. I'll try this but let me know if you have any more thoughts.. thanks.

  8. #8
    Join Date
    May 2005
    Posts
    1,191
    Yes, I would just add that to the criteria like so:
    Code:
    Public Function checkResponses(sFormName As String) As Boolean
    
    Dim ctl As Control
    
    For Each ctl In Forms(sFormName).Controls
        Select Case ctl.ControlType
            Case acOptionGroup, acComboBox, acTextBox
                If IsNull(ctl.Value) AND ctl.enabled Then
                    ctl.BackStyle = 1
                    ctl.BackColor = 6773995
                    ctl.BorderColor = 6773995
                    
                    checkResponses = True
                End If
        End Select
    Next ctl
    
    End Function
    Again, untested.
    Me.Geek = True

  9. #9
    Join Date
    Feb 2009
    Posts
    22
    Thanks - that works great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •