467,880 Members | 1,246 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,880 developers. It's quick & easy.

Transferring ID from one Multiselect Listbox to another

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
  • viewed: 1639
Share:
1 Reply
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

Post your reply

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

Similar topics

2 posts views Thread by Sally | last post: by
2 posts views Thread by Cassie Pennington | last post: by
2 posts views Thread by Steph | last post: by
3 posts views Thread by kaosyeti via AccessMonster.com | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.