Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. filtering in Access with VB

filtering in Access with VB

Scheduled Pinned Locked Moved Visual Basic
helptutorialdatabasequestioncareer
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hello, I want to filter a search of my records in teh database, but am a little perplexed as to how to filter more than one criteria. This is what I am trying to do. On my Main Menu Form, there is an option to "Look up friends by area code." These area codes are in a drop down menu, so if the user selects '123' for example, then it will open a new form (friend_frm) and every friend in area code '123' will be listed. My problem is, I have a field in the frm_friend, called active/passive. I do not want friends to show up if they are listed as passive. I don't know how to incorporate this into my filter. Private Sub Command97_Click() On Error GoTo Err_Command97_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frm_friend" stLinkCriteria = "[Area Code]=" & Me![Combo94] DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command97_Click: Exit Sub Err_Command97_Click: MsgBox Err.Description Resume Exit_Command97_Click End Sub What do I add to "stLinkCriteria' to make it filter out the subset of the records of friends who are in a particular area code? If anyone knows how to do this, I'd be very appreciative. Thank you very much. Nick

    J 1 Reply Last reply
    0
    • A Anonymous

      Hello, I want to filter a search of my records in teh database, but am a little perplexed as to how to filter more than one criteria. This is what I am trying to do. On my Main Menu Form, there is an option to "Look up friends by area code." These area codes are in a drop down menu, so if the user selects '123' for example, then it will open a new form (friend_frm) and every friend in area code '123' will be listed. My problem is, I have a field in the frm_friend, called active/passive. I do not want friends to show up if they are listed as passive. I don't know how to incorporate this into my filter. Private Sub Command97_Click() On Error GoTo Err_Command97_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frm_friend" stLinkCriteria = "[Area Code]=" & Me![Combo94] DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command97_Click: Exit Sub Err_Command97_Click: MsgBox Err.Description Resume Exit_Command97_Click End Sub What do I add to "stLinkCriteria' to make it filter out the subset of the records of friends who are in a particular area code? If anyone knows how to do this, I'd be very appreciative. Thank you very much. Nick

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      This has nothing to do with link criteria. Make your data source SQL be something like this:

      SELECT * FROM Friends WHERE Friends.ActivePassive="Active"

      OR

      SELECT * FROM Friends WHERE Friends.Active=True

      "Do unto others as you would have them do unto you." - Jesus
      "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups