By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,640 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,640 IT Pros & Developers. It's quick & easy.

Open and filter form results based on 2-criteria

P: 32
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_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "devicelistA"

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

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit Sub

MsgBox Err.Description
Resume Exit_addPort_Click

End Sub
Jun 1 '07 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 295
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
Jun 2 '07 #2

P: 32
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"
Jun 2 '07 #3

Expert Mod 10K+
P: 14,534
Try this ...

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[SiteID]=" & Me![SiteID] & " and [Category]='switch'"
Jun 2 '07 #4

P: 32
It worked fine, Thanks for help!
Jun 4 '07 #5

Expert Mod 10K+
P: 14,534
It worked fine, Thanks for help!
You're welcome.
Jun 4 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.