473,624 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display limited items in the listbox according to the value of some field

11 New Member
Hi experts:
When I design the input form for customers' data, I divide the address into three parts: City, Borough, and RestAddress, where City and Borough are of the listbox type. I have two tables as follows. I would like to do the following. For example, if I choose "New York City" in the City listbox, then only the corresponding boroughs (Manhattan, Bronx, and Queens) of New York City will show up in the Borough listbox.

In the design view, I would like to try the SQL statement in the "Row Source" of Borough.Borough Name as follows, in which "?" means the content of the CityID field already inputted. So what is "?" ?

SELECT * from Borough WHERE CityID = ?



TABLES:

City:
ID CityName
1 New York City
2 Boston
...

Borough:
ID CityID BoroughName
1 1 Manhattan
2 1 Bronx
3 1 Queens
4 2 Holly Woods
5 2 Santa Monica
6 2 Pasadena
...
Aug 22 '08 #1
3 1362
hjozinovic
167 New Member
We discussed very similar question here
Aug 22 '08 #2
yltang
11 New Member
Thanks for the reference. Well, there are a lot of discussions and the names of tables, variables, etc., are very confusing. Let me state my problem specifically. I have three tables: City, Area, and Customer:

City:
CityID: Autonumber
CityName: Text

Area:
AreaID: Autonumber
AreaName: Text
CityID: Number (Lookup: from City)

Customer:
CustomerID: AutoNumber
CustomerName: Text
CityID: Number (Lookup: from City)
AreaID: Number (Lookup: from Area)

I have also created a form named “Customer,” and it has basically 4 fields to fill: CustomerID, CustomerName, CityID, and AreaID, in which CityID and AreaID are both combo boxes with control names, "cboCity" and "cboArea", respectively.

I created the following program, but it doesn’t work. The system pops up a window asking me to input the value of variable "Me.cboArea.Lis tIndex." But if I give a correct number it works OK. Can anybody give some suggestion about the program? Thanks in advance.


------------------------------

Private Sub cboCity_AfterUp date()
Me.cboArea.RowS ource = "SELECT DISTINCTROW AreaID, AreaName FROM Area WHERE (CityID = Me.cboCity.List Index)"
Me.cboArea.Requ ery
End Sub

-----------------------------
Aug 26 '08 #3
hjozinovic
167 New Member
try changing the WHERE part like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboCity_AfterUpdate()
  2. Me.cboArea.RowSource = "SELECT DISTINCTROW AreaID, AreaName FROM Area WHERE (CityID = " & Me.cboCity.ListIndex & ")"
  3. Me.cboArea.Requery
  4. End Sub
Aug 26 '08 #4

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

Similar topics

5
14025
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer than the listbox size. Please refer to this link to get the idea of what I would like to do. Unfortunately this one is for VB.
1
6342
by: Claire | last post by:
As a Listbox.item, rather than using a string I'm using a ListItems object, overriding the ToString method When I add items to listbox.items, my strings are shown correctly. On the otherhand, when I update the "value" field the listbox doesn't update to reflect the new value. What do I need to do to the following code to correct this please (if it's possible) ? public class ListItems
1
3100
by: NBB | last post by:
I can't figure this one out. Here's the situation, should be pretty for the pros in here. I have a ListBox that is populated with the DataTextField and DataValueField flags of the DataSet. Everything populates just fine and works great. The DataTextField displays text from a database column called Path, which is the absolute URL of a file. What I would like it to display is just the filename, essentially trimming off everything...
4
3705
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to find what I need so I can populate a DB. lstTest is dim'd as a ListBox, and I thought I could just do:
3
6096
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save the list back to the database. First of all, I implemented the re-ordering through client-side javascript, which worked great (also it didn't require a postback every time an item was re-ordered). For testing purposes, I'm outputting the contents...
8
1886
by: tshad | last post by:
I have a string that I read from my database: 1|8|5620|541 These are all values in my ListBox. I want to select each of these items (4 of them - but could be many more). At the moment I am doing the following: Dim a() As String Dim j As Integer a = JobCategoriesSelected.Split("|") ' Where JobCategoriesSelected is set to 1|8|5620|541 For j = 0 To a.GetUpperBound(0)
3
5036
by: Will Chamberlain | last post by:
I am running into a strange error when I try debugging my current application. A form loads up with a dynamically-populated textbox full of software titles. Upon selection of a software title and pressing 'GO' a checkboxlist is displayed with the users who use the current software. The checkboxlist is bound to a dataset named "DataTable" and has the DisplayMember set to "Employee" and the DataValue set to "ID", like the following: ----...
1
12771
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to add the option to the listbox. It works for <select> or <asp:listbox> controls. var opt = document.CreateElement("OPTION"); opt.text = "test"; opt.value="test";
5
2843
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that is what the ListBox uses for its display. Correct?
0
8672
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
8614
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
8330
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
8471
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...
0
7153
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
6107
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
5561
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
4075
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...
2
1474
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.