Cascading Combo Box Filtering

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #61
    1. Get Z the string that got printed in the immediate window
    2. Set Option Explicit in line 2 of your code
    3. Compile your database and fix the errors. If you need help, then possibly a new thread might be in order for just that question.

    Comment

    • dgaletar
      New Member
      • Jan 2013
      • 72

      #62
      OK, right now, when I execute the form I get the following Microsoft Visual Basic for Applicati... error box: Compile error; Syntax error. Line 1 (Private Sub Combo14_Click() ) is highlighted in yellow, and line 7 ( zstrSQL = "SELECT [CUA#] " &) is highlighted in blue.

      Comment

      • dgaletar
        New Member
        • Jan 2013
        • 72

        #63
        Sorry, I posted that before I saw your post.

        1. From the immediate window:

        Code:
        resolved string is::: SELECT [CUA#] FROM [VEHICLE_DETAILS] WHERE [Department]=4
        2. I put "Option Explicit" in line 2 of the VBA code and moved "Dim zstrSQL As String" to line 3. I got another compile error: "Invalid inside procedure".

        3. I have to google "Compile you database" so it may take ma a while.

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #64
          To compile your database, you just need to click on the Debug menu in the VBA editor and click Compile your database name.

          Sorry, by line 2, I was meaning line 2 of what you posted in post 52. It should go right below the Option Compare Database. So at this point, your code should look like this:
          Code:
          Option Compare Database
          Option Explicit
           
              Private Sub Combo14_Click()
              Dim zstrSQL As String
                  With Me![CUA#]
                      If IsNull(Me!Department) Then
                          .RowSource = ""
                      Else
                          zstrSQL = "SELECT [CUA#] " & _
                              "FROM [VEHICLE_DETAILS] " & _
                              "WHERE [Department]=" & Me!Department
              'Let us see the string
                          Debug.Print "resolved string is::: " & zstrSQL
                          .RowSource = zstrSQL
                      End If
                      .Requery
                  End With
              End Sub
          Once you have compiled your database with out getting any errors, try replacing line 6 with
          Code:
          With Me.Combo26

          Comment

          • dgaletar
            New Member
            • Jan 2013
            • 72

            #65
            Thank you again, Seth, for continuing to help me through this.

            I did as you said first, clicked on "Compile" under "Debug" and selected my database but nothing happened.

            So I switched line 6 code like suggested and...

            IT WORKS!!!

            You did it Seth!!! Thank you sooooo much!

            I'll have to figure out how to open the corresponding form from here, but THANK YOU!!!

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #66
              Glad to be able to help!

              A quick nudge for your other problem, Google DoCmd.OpenForm and DoCmd.SearchFor Record. If you need any futher help with that, just start a new thread since that is a new problem.

              Comment

              • dgaletar
                New Member
                • Jan 2013
                • 72

                #67
                Awesome! Thanks bud!

                Somehow that was as easy as 1, 2, 3! Thanks!
                Last edited by NeoPa; Feb 15 '13, 05:57 PM. Reason: Merged posts.

                Comment

                Working...