473,508 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open and filter form results based on 2-criteria

32 New Member
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_addPort_Click:
Exit Sub

Err_addPort_Click:
MsgBox Err.Description
Resume Exit_addPort_Click

End Sub
Jun 1 '07 #1
5 2618
maxamis4
295 Recognized Expert Contributor
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
NewtoAccess
32 New Member
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
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[SiteID]=" & Me![SiteID] & " and [Category]='switch'"
  2.  
Jun 2 '07 #4
NewtoAccess
32 New Member
It worked fine, Thanks for help!
Jun 4 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
It worked fine, Thanks for help!
You're welcome.
Jun 4 '07 #6

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

Similar topics

3
6592
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
2
2599
by: Terry | last post by:
I have cerated a Form, ExamsFrm, which is used to input details of exams taken at several Centres. It dosplays details from StudentTbl and has a SubForm which displays details from ExamsTble. I...
8
6510
by: dick | last post by:
I am just trying to print/report the results of a "filter by selection" which is done by right-clicking a form, filling in values, and "applying the filter." I have searched the newsgroups, and...
0
2725
by: Colin | last post by:
In access 2000 I need to filter records in a Subform by pushing a button on a command button located on the Main form. The Main form is blank. Its only purpose is to contain the subform which is...
3
2749
by: Tony Williams | last post by:
Sorry to repost but I cannot work this out. Can anyone come up with a suggestion? I have a main form based on Table1. The form has a tab control of three pages. Each page has a subform based on a...
1
5295
by: starke1120 | last post by:
Is there a way to open a form based on query type.. Example.. If a certain query result is 1 then open the form to this result.. If the query results are NULL or 0 results, then open open for...
1
1791
lwwhite
by: lwwhite | last post by:
When a user clicks OK on form "SelectDefaults," I want to open form "Welcome" if the results of query "qry_todo_overdue" = 0 or form "OverdueToDo" if the results >= 1. First, I assume that I need to...
5
2782
by: favor08 | last post by:
have a mainform called PendingsMain and a subform called PendingsSub. You can filter the subform by different filters and this works fine. i want to create a report that will print out the...
6
4171
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in...
27
4368
stonward
by: stonward | last post by:
Hi again People. This Forum has been a serious help for me...I'm sure you know how it is...you get pretty good at handling Access when wham! you come across something you just can't figure - and...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.