473,748 Members | 4,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List query

Need help setting a select query where person enters a list of zipcodes
to lookup. I want to prompt the user to enter all the zip codes, then
run the query against to table to pull all records. Thanks.

May 22 '06 #1
2 1396
This example assumes the person enters the zip codes into a text box,
separating them with spaces. You set the AfterUpate property of the text
box to [Event Procedure]. In this event, you save any edits that are in
process, parse the zip codes into an array, and build that into a string to
use as the Filter of the form. The field to be filtered is a Text type
field, named Zip. If the user entered no zip codes, you show all records.

Private Sub txtZipList_Afte rUpdate()
Dim strWhere As String
Dim strWord As String
Dim varZips As Variant 'Array of zip codes
Dim i As Integer
Dim lngLen As Long

If Me.Dirty Then 'Save first.
Me.Dirty = False
End If

If Not IsNull(Me.txtZi pList) Then 'Show all if blank.
varZips = Split(Me.txtZip List, " ")
'Build up the Where string from the array.
For i = LBound(varZips) To UBound(varZips)
strWord = Trim$(varZips(i ))
If strWord <> vbNullString Then
strWhere = strWhere & """" & strWord & """, "
End If
Next
'Remove trailing comma and space, and use IN.
lngLen = Len(strWhere) - 2
If lngLen > 0 Then
strWhere = "[Zip] IN (" & Left(strWhere, lngLen) & ")"
End If
End If

'Apply the filter.
If strWhere <> vbNullString Then
Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<fo*******@mart ecgroup.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Need help setting a select query where person enters a list of zipcodes
to lookup. I want to prompt the user to enter all the zip codes, then
run the query against to table to pull all records. Thanks.

May 22 '06 #2
fo*******@marte cgroup.com wrote in
news:11******** **************@ i40g2000cwc.goo glegroups.com:
Need help setting a select query where person enters a list of
zipcodes to lookup. I want to prompt the user to enter all
the zip codes, then run the query against to table to pull all
records. Thanks.

To have the query prompt:
SELECT * from ZipCodes WHERE zipcode IN ([Enter zipcodes with comma
between])

To get the list from a textbox:
SELECT * from ZipCodes WHERE zipcode IN ([Forms!myform!tx tZiplist])
--
Bob Quintal

PA is y I've altered my email address.
May 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12158
by: lastusernameleft | last post by:
Is there a .NET method for doing this? I haven't found anything else that works. Thanks
4
2811
by: MSD | last post by:
I am running a report that uses a query as its record source and opens a form collecting beginning and ending item numbers to feed to the query. This works, but now I'm trying to use the result of a multi-select list box on the form to feed multiple item numbers to the query. In other words - if you pick item #100,105,110 from the list box, the query should display information for those 3 items. If I type 'IN (100,105,110)' in the...
2
2204
by: ormy28 | last post by:
I really need some help with the following problem if anyone would be willing. I need a list box to list the opposite of what appears in a query. Heres the details: My database is for a doctors surgery, and this includes the tables tblPatients, tblDoctors and tblAppointments. tblAppointments has an Appointment ID and also includes the Patient ID (from tblPatient) and Doctor ID (from tblDoctor) plus the start and end time of the
0
3516
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list boxes do not necessarily need to have a selection made to be used in the dynamic query. In essence the form can have selections made in all or none of its list boxes to form the dynamic query I am looking to get some feedback in reference to...
2
14748
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
6
2746
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
1
2242
by: Stephene | last post by:
New to the world of web design/php/mysql and need help please. What I'm trying to do: I would like a web page with three drop down menus each populated by a query The first represents locations ie Room1, Room2 etc The second represents locations within the rooms i.e Rack1, Rack2 etc
3
3512
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings form has an unbound combo box listing all the meetings in the database allowing the user to navigate between meeting records. The meetings form also has a list box that displays a list of members associated with a meeting.
5
1685
by: JvC | last post by:
Background Access 2003. MDB Front End. I am populating a list box with the names of queries in the system. I am searching for strings in the query names and then creating a value list for users to select from. Problem My users occasionally use commas in query names. When I move the value list to the RowSource of the list box, the commas in the names are being interpreted as list separators. If my RowSource is:
0
2078
by: c0mrade | last post by:
I have a problem with getting the list items, below is my hibernate code, after that code there is my method ..and below that is my junit test. How can I make sure that query is executing properly, and how can I check that results actually work .. this query should return couple of pids .. and put them in the list.. now I'm 90 % sure that my list is always empty .. instead it should have 3 pids : 4573, 4593, 4693 .. can anyone figure it out what...
0
8987
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
8826
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,...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
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
8239
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3303
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
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
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.