filtering in Access with VB
-
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
-
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
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