473,662 Members | 2,588 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_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
Jun 1 '07 #1
5 2628
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
6605
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 the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
2
2602
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 have incorporated some VB6 code as well as some Conditional Formatting. The code automatically updates CheckBoxes in the SubForm, depending on exam results, and the Conditional Formatting changes background colours, depending on CheckBox datum. ...
8
6529
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 there are many examples. BUT, they fail sometimes. The techique is to pass the form's Me.filter as the "where condition" in a Docmd.openreport statement in code behind a "print button" on the form.
0
2747
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 in a datasheet format. So far… 1)I have created a query called "CatFilterQuery" which results in a prompt to enter the "category field" to filter on. 2)Created a macro called "FilterCategory" which is based on the query mentioned above and uses...
3
2763
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 different table ie subform1 based on Table2, subform2 based on Table3 and subform3 based on Table4. I want the user to be able to use the Filter By Form facility in Access but this does not work when trying to select controls on the main form AND...
1
5309
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 in add or add new record form. The query will return one to 0 records so this is my option. Im guessing the form load event would be the place but not sure how to go about it.
1
1807
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 run the query in "SelectDefault's" OnOpen event, right? But having done that, I'm not sure how to incorporate the query-checking into an If...Then statement on the OK button's OnClick event. Here is the query's SQL: SELECT Count(*) AS Expr1...
5
2791
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 results of the users filters or print everything if there is no filters submitted within the form. Any suggestions
6
4176
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 several combo boxes on the form. The filter is updated whenever the user changes his/her selection. My problem is when the user selects a filter option that is not present in the data. The filter works fine - no records are displayed; however, the...
27
4387
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 if you're in a hurry at all....! I have a Main Form, based upon my main table (products). This main form has a subform (based upon a query that is based primarily upon the Products table, plus a few others to grab hold of related data (customer...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8546
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
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 we have to send another system
2
1752
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.