473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Filter listbox/combo box based on value of field?

RRT
I have an existing table which describes Streets and sections of streets
between intersections:

Table 1: Streets by Intersections
Street Area
Ann St. Main to Jackson
Ann. St. Jackson To Summer
Ann St. Summer to End
Joe St. Aberdeen to Mike
and so on for 1200 records

My second table is:
Table 2: Work by Street
Project Street Area Project
Description
2003-01 Ann St. Jackson to Summer Sanitary Renewal

In table 2 I'd like to be able to pick "Area" from a listbox and only have
the entries that relate to that particular street showing. In the case of
Ann St that would be 3 choices rather than trying to wade through 1200.

Is there an easy way to filter listbox based on the value in a field? Hope
this makes sense.

Thanks

RRT




Nov 12 '05 #1
3 26632
Certainly, you can simply, using a fully-qualified reference, refer to the
Control on the Form in the Criteria of the Query. Whenever the corresponding
Control (in your case, the listbox) changes, you need to requery the target
List or Combo Box... so, do so in the afterupdate event of the Listbox.

Larry Linson
Microsoft Access MVP

"RRT" <NO******************@miramichi.org> wrote in message
news:Gt********************@ursa-nb00s0.nbnet.nb.ca...
I have an existing table which describes Streets and sections of streets
between intersections:

Table 1: Streets by Intersections
Street Area
Ann St. Main to Jackson
Ann. St. Jackson To Summer
Ann St. Summer to End
Joe St. Aberdeen to Mike
and so on for 1200 records

My second table is:
Table 2: Work by Street
Project Street Area Project
Description
2003-01 Ann St. Jackson to Summer Sanitary Renewal

In table 2 I'd like to be able to pick "Area" from a listbox and only have
the entries that relate to that particular street showing. In the case of
Ann St that would be 3 choices rather than trying to wade through 1200.

Is there an easy way to filter listbox based on the value in a field? Hope this makes sense.

Thanks

RRT




Nov 12 '05 #2
"RRT" <NO******************@miramichi.org> wrote in
news:Gt********************@ursa-nb00s0.nbnet.nb.ca:
I have an existing table which describes Streets and sections
of streets between intersections:

Table 1: Streets by Intersections
Street Area
Ann St. Main to Jackson
Ann. St. Jackson To Summer
Ann St. Summer to End
Joe St. Aberdeen to Mike
and so on for 1200 records

My second table is:
Table 2: Work by Street
Project Street Area
Project Description
2003-01 Ann St. Jackson to Summer Sanitary
Renewal

In table 2 I'd like to be able to pick "Area" from a listbox
and only have the entries that relate to that particular
street showing. In the case of Ann St that would be 3 choices
rather than trying to wade through 1200.

Is there an easy way to filter listbox based on the value in a
field? Hope this makes sense.
In the Current Event for your form, change the rowsource of the
listbox to a filtered one, and requery.

sub Form_current()
dim strSQL as string
strSQL = "SELECT Street, Area from [table 1] " & _
"Where street = '" & me.street & "'"
me.listbox.recordsource = strSQL

end sub
Thanks

RRT





Nov 12 '05 #3
RRT
>
I have an existing table which describes Streets and sections
of streets between intersections:

Table 1: Streets by Intersections
Street Area
Ann St. Main to Jackson
Ann. St. Jackson To Summer
Ann St. Summer to End
Joe St. Aberdeen to Mike
and so on for 1200 records

My second table is:
Table 2: Work by Street
Project Street Area
Project Description
2003-01 Ann St. Jackson to Summer Sanitary
Renewal

In table 2 I'd like to be able to pick "Area" from a listbox
and only have the entries that relate to that particular
street showing. In the case of Ann St that would be 3 choices
rather than trying to wade through 1200.

Is there an easy way to filter listbox based on the value in a
field? Hope this makes sense.


In the Current Event for your form, change the rowsource of the
listbox to a filtered one, and requery.

sub Form_current()
dim strSQL as string
strSQL = "SELECT Street, Area from [table 1] " & _
"Where street = '" & me.street & "'"
me.listbox.recordsource = strSQL

end sub


I should of mentioned I don't use forms, I enter information directly into
tables. So I guess I could use SQL on the rowsource. What would I need to
enter?

SELECT Street, Area from [Streets By Intersections]
WHERE Street=' & street &'

Just guessing....


Nov 12 '05 #4

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

Similar topics

7
by: Eddy Scheire | last post by:
Hi all, I've got this listbox and this text field on an ASP page. Now I want the item I click on in the listbox to appear in the text field and I can't find the code nowhere for what seems to me...
3
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...
1
by: Cassie Pennington | last post by:
I have tried to filter one combo box based on a selection in another combo box, by using the following sample code: tblfield=forms!!. However, the combobox only seems to recognise the first...
4
by: S. van Beek | last post by:
Dear reader, By a Date field with Now() as default value the content of the field is date plus time. As I need a filter in a query on date only (excluding time) I invented the following...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
1
by: RockNRoll | last post by:
I'm new to ASP.NET and need to filter a datagrid based on a textbox value. I have a working datagrid and would like the WHERE part of my SQL statement to call the value of a textbox and refresh...
1
by: Sam | last post by:
Hi, I don't know how to specify the display and value field for a combobox when using AddRange to fill the combo. Here is what I have so far: -A function to build an array of object : Dim...
0
by: marcelo | last post by:
Could you help me out here. I need to accomplish this: I need to filter listbox items from by entering some characters to the textbox. But the problem is that items (files that are read from...
8
by: nezzy | last post by:
Hi, I'm new to the forum so please excuse my lack of knowledge. I have a combo box containing a training date (combo box is sourced from tblTrainingCourse). I'd like to filter this combo box...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.