473,473 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Transferring ID from one Multiselect Listbox to another

2 New Member
Hi all,

I was wondering whether somebody might be able to help me with a question I have on a MS Access Database I'm building.

I have created a search form with a few multiselect listboxes. What I'd ultimately like is for the selection(s) in one listbox to filter the second listbox, but am struggling to find a way to do this. I have looked at some of the other solutions on this forum but not been able to find one that works on my database.

My multiselect listboxes are:

1) lstRegion - Looking at table "Regions" with fields: "Region ID" and "Region"
(i.e. Asia, Europe etc)

2) lstCountry - Looking at table "Countries" with fields "Region ID" (to link to
Regions table), "Country ID" and "Country"


I have the following After-update code for lstRegion currently:

Expand|Select|Wrap|Line Numbers
  1. Private Sub lstRegion_AfterUpdate()
  2. Dim i As Integer
  3. Dim strIN As String
  4.  
  5. For i = 0 To lstRegion.ListCount - 1
  6.         If lstRegion.Selected(i) Then
  7.             strIN = strIN & "'" & lstRegion.Column(0, i) & "',"
  8.         End If
  9.  
  10.     Next i
  11.  
  12. End Sub

I think what I need to do is add a line of code in this function that takes the region ID values stored in "strIN" and sets the row source of Countries Listbox to show only those Region IDs selected in Regions list box.

P.S I also have 2 command buttons for lstRegion that allow me to select all, or clear all selections made in the listbox. This is working fine :o)

Would be grateful for any suggestions.

Thanks in advance,

Amit

P.S Sorry I forgot to mention that each of the IDs in the String are separated as follows '1','2' etc. I think it's a comma delimited string or something along those lines.
Feb 20 '08 #1
1 1826
asharma0001
2 New Member
SQL for Countries table is:

SELECT Countries.[Region ID], Countries.[Country ID], Countries.Country
FROM Countries


Can I use the following? - SELECT Countries.[Region ID], Countries.[Country ID], Countries.Country FROM Countries WHERE Countries.[Region ID] = strIN

Or is it more complex than that?

Thanks.
Feb 21 '08 #2

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

Similar topics

2
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
2
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
2
by: Alan Lane | last post by:
Hello world: I'm using Access 2003. I have 2 listboxes. One is a single column. The other has two columns. I can use Dev Ashish's code (thanks Dev!) from the Access MVP Website to accumulate...
2
by: Steph | last post by:
I have created a multiselect list box control (lbx_comorb) that is populated from a datatable (dt_ptAdmission). The list box populates now problem at all. However the issue is when I load the...
2
by: ttime | last post by:
I've got a form that uses a multiselect listbox. When a user is selected from a combo box, values are populated into this listbox associated with that user. The problem is, if one person has say...
1
by: IMK | last post by:
Hello all, Sorry if this issue has come up already but I am new to vb.net. Thanks. I am trying to retrieve the selectedvalues from a multiselect list box in a vb 2005 winform. Here is the code...
3
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
5
by: martin DH | last post by:
Hello, The details are below, but I have a simple form (Form1) with two objects and a "search" command button. When the two objects are cascading combo boxes (the form creates the parameters for a...
5
by: erbrose | last post by:
Hey all, newbie to vb here. I've created a listbox (called lst_county) that gets populated from a Select * From Table in Oracle on load. I've set the MultiSelect to 2 -Extended. I've got some code...
0
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...
0
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
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
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.