473,583 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ 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 1841
asharma0001
2 New Member
SQL for Countries table is:

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


Can I use the following? - SELECT Countries.[Region ID], Countries.[Country ID], Countries.Count ry 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
6358
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 want to do this as the selections are being made not after-the-fact after all selections are made. Thanks! Sally
2
3347
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 variable data. Any clues as to how I can write several items to an SQL statement from a multiselect listbox to update a report? Thanks in...
2
6065
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 the values from the bound column of a MultiSelect listbox, so that I can include them in a SQL query that will then be the recordsource for a...
2
1948
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 webform, when there is already admission data. I need the populated list box (lbx_comorb) to show the items that were previously selected for this...
2
1594
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 10 entries in the listbox, and selects the last 3-4, and the next user only has 2 entries, those last 3-4 rows are still highlighted in the listbox....
1
3181
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 I am using so far: dim i as object For Each i In Me.lstUnitPicklist.SelectedItems
3
3617
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 in a text box? then, how can i have a second selected item show up in a different text box, without affecting the 1st one? (lboxOptions,...
5
4238
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 query - Query1), the query returns my results proper. But when the two objects are cascading combo-then-multiselect listbox (the perferred format in...
5
5645
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 that sends out the select rows from lst_country to a msgbox (all working fine). What i need to do now is to actually put those selected rows into an...
0
7824
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...
1
7931
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...
0
6578
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...
0
5370
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...
0
3816
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...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2331
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
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1154
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...

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.