Open and filter form results based on 2-criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NewtoAccess
    New Member
    • May 2007
    • 32

    Open and filter form results based on 2-criteria

    Hi its me again.

    I want to filter data by 2-different values. First I want to filter data by site and then by server. the first value is obtained from a list box-this works fine, then I want the same list filtered by the text "server" in my code.

    Must be a syntax error, see below, Thanks

    Private Sub addPort_Click()
    On Error GoTo Err_addPort_Cli ck

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "devicelist A"

    stLinkCriteria = "[SiteID]=" & "'" & Forms!datacente rmain![List0] & "'"
    stLinkCriteria = "[Category]=" = Server

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_addPort_Cl ick:
    Exit Sub

    Err_addPort_Cli ck:
    MsgBox Err.Description
    Resume Exit_addPort_Cl ick

    End Sub
  • maxamis4
    Recognized Expert Contributor
    • Jan 2007
    • 295

    #2
    so just to understand what you want, You want your search box to find the site first. Then once you have selected the site, you want the same search box to take all the servers from that site and allow you to pick the values from that box?

    If this is the case I would not recommend this method at all. Use two boxes and once you select the site hide the first one and make the second display itself. That would be my approach on the filtering. As far as allowing your second list box to display specific information from one site, in the list box source control and include the name of the first list box as the criteria needed to return results. If you can provide more details such as names of controls and tables, I could help you design something that would probably work.


    good luck
    Last edited by maxamis4; Jun 2 '07, 01:41 AM. Reason: bad grammer

    Comment

    • NewtoAccess
      New Member
      • May 2007
      • 32

      #3
      Im using a value from a previously selected list box to set criteria-which works however -simultaneously- I would like to filter records based on text I have pretyped code.
      The later portion im unable to figure out.

      must be my syntax

      stLinkCriteria = "[SiteID]=" & Me![SiteID] & "and[Category]="&"switch"

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Try this ...

        [code=vb]
        stLinkCriteria = "[SiteID]=" & Me![SiteID] & " and [Category]='switch'"
        [/CODE]

        Comment

        • NewtoAccess
          New Member
          • May 2007
          • 32

          #5
          It worked fine, Thanks for help!

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by NewtoAccess
            It worked fine, Thanks for help!
            You're welcome.

            Comment

            Working...