Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    5

    Unanswered: Cascading Control Box

    I am desperate for assistance. I have been trying for days to write the VB code to have cascading control boxes to no avail. I saw the post from Paul but still couldn't figure out what I am doing wrong. Obviously I am a beginner! I am trying to have a user select a department, based upon the department, have a list of questions to select from and then once select the question, to have the answer populated-all on one form. Can anyone tell me what I am doing wrong?
    Attached Files Attached Files

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    First, you have a lookup field, which isn't a good idea:

    The Access Web - The Evils of Lookup Fields in Tables

    so the question of whether you're looking for a text or numeric value is confusing. Second, the field name is "QuestionText" rather than "Scenario: QuestionText". Third, it's QuestionText not QuestionsText as you have it in code. Fourth, the row source type on the last combo should be Table/Query. This code appears to work:

    Code:
    Private Sub Department_AfterUpdate()
      Dim strSQL        As String
    
      strSQL = "SELECT [QuestionText] " _
             & "FROM [Questions] " _
             & "WHERE Department = '" & Me.Department.Column(1) & "'"
    
      Me.QuestionText.RowSource = strSQL
    
    End Sub
    
    Private Sub QuestionText_AfterUpdate()
      Dim strSQL        As String
    
      strSQL = "SELECT [QuestionAnswer] " _
             & "FROM [Questions] " _
             & "WHERE [QuestionText] = '" & Me.QuestionText & "'"
    
      Me.QuestionAnswer.RowSource = strSQL
    End Sub
    Paul

  3. #3
    Join Date
    Jan 2009
    Posts
    5
    Thank you so much! You are downright awesome! The only thing is that I wanted the QuestionAnswer to auto populate after the QuestionText is selected, right now I have to click on the drop down to display it.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problemo! Try adding this line after setting the row source:

    Me.QuestionAnswer = Me.QuestionAnswer.ItemData(0)
    Paul

  5. #5
    Join Date
    Jan 2009
    Posts
    5
    You are the best! Thank you so much for taking the time to respond to posts for people like me. I have been drowning and you just saved me. Your effort is truly appreciated!

Posting Permissions

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