By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,838 Members | 1,675 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,838 IT Pros & Developers. It's quick & easy.

Select Multiple value from Listbox in MS Access

100+
P: 101
Hi,
My Project is in MS Access.
In that I have one form in which I have some textboxes,comboboxes and listboxes.
Now when I select value from 1st combobox(CustomerID) then it wil generate list for 1st listbox(PalletNo).
Now I want to select miltiple values from that 1st listbox(PalletNo).
and based upon this selection from 1st listbox(PalletNo) and combobox(CustomerID) I want to generate list for 2nd listbox(PONo).

For example

CustomerID PalletNo PONo
1000 28300 12345
1001 28301 12346
1000 28302 12345
1000 28303 12345
1002 28304 12347
1003 28305 12348
1000 28306 12350
1000 28307 12350

So when I select 1000 from 1st Combobox(CustomerID) then it will generate list for 1st Listbox(PalletNo).
like this
CustomerID PalletNo
1000 28300
28302
28303
28306
28307


Now when I select multiple values from that Listbox(PalletNo) then it will generate list for 2nd listbox(PONo)
like
CustomerID PalletNo PONo
1000 28300 12345
28302 12345
28307 12350


I don't know how to do this.
->how to select multiple values from listbox?
->how can I generate list if I select multiple values from listbox?
Can anyone help me?
Thanks in Advance.
Jan 15 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 374
Hi,
My Project is in MS Access.
In that I have one form in which I have some textboxes,comboboxes and listboxes.
Now when I select value from 1st combobox(CustomerID) then it wil generate list for 1st listbox(PalletNo).
Now I want to select miltiple values from that 1st listbox(PalletNo).
and based upon this selection from 1st listbox(PalletNo) and combobox(CustomerID) I want to generate list for 2nd listbox(PONo).

For example

CustomerID PalletNo PONo
1000 28300 12345
1001 28301 12346
1000 28302 12345
1000 28303 12345
1002 28304 12347
1003 28305 12348
1000 28306 12350
1000 28307 12350

So when I select 1000 from 1st Combobox(CustomerID) then it will generate list for 1st Listbox(PalletNo).
like this
CustomerID PalletNo
1000 28300
28302
28303
28306
28307


Now when I select multiple values from that Listbox(PalletNo) then it will generate list for 2nd listbox(PONo)
like
CustomerID PalletNo PONo
1000 28300 12345
28302 12345
28307 12350


I don't know how to do this.
->how to select multiple values from listbox?
->how can I generate list if I select multiple values from listbox?
Can anyone help me?
Thanks in Advance.
It is very easy to do. just pay very close attention to how this is done.


First you need to have all combinations of possibilities in one table in your database.

that will massively simply things.

then for the first item. you simply create a rowsouce by going into the properties of that combo box and then go to rowsource and then click on the .... button to create your query.

copy and paste this into the rowsource property:

Expand|Select|Wrap|Line Numbers
  1.            SELECT CustomerID FROM [TABLENAME] GROUP BY CustomerID
  2.  
Please make sure to put the name of the table that will have the list of customerID's in to in place of [TABLENAME] this way. it knows what table to look at.

also on the property of the CustomerID Combo box you will need to scroll down to the property On Change event. When that is selected, then you need to select the ... button again and select Code Builder.

Then type the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub subtxtControl_Change()
  2.     Me.PalletNo.RowSource = "SELECT ProjectCodeLookup FROM IMG_TLY_XREF_GROUP_LIST WHERE PROJECTPREFIXLOOKUP = '" & Me.subtxtControl.Value & "'"
  3.     Me.PalletNo.Requery
  4.     Me.Repaint
  5. End Sub
  6.  
replace the Field names and table names with your table names and fields.

Hope that helps,

Joe P.
Jan 22 '08 #2

100+
P: 101
It is very easy to do. just pay very close attention to how this is done.


First you need to have all combinations of possibilities in one table in your database.

that will massively simply things.

then for the first item. you simply create a rowsouce by going into the properties of that combo box and then go to rowsource and then click on the .... button to create your query.

copy and paste this into the rowsource property:

Expand|Select|Wrap|Line Numbers
  1.            SELECT CustomerID FROM [TABLENAME] GROUP BY CustomerID
  2.  
Please make sure to put the name of the table that will have the list of customerID's in to in place of [TABLENAME] this way. it knows what table to look at.

also on the property of the CustomerID Combo box you will need to scroll down to the property On Change event. When that is selected, then you need to select the ... button again and select Code Builder.

Then type the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub subtxtControl_Change()
  2.     Me.PalletNo.RowSource = "SELECT ProjectCodeLookup FROM IMG_TLY_XREF_GROUP_LIST WHERE PROJECTPREFIXLOOKUP = '" & Me.subtxtControl.Value & "'"
  3.     Me.PalletNo.Requery
  4.     Me.Repaint
  5. End Sub
  6.  
replace the Field names and table names with your table names and fields.

Hope that helps,

Joe P.
Thanks for ur reply but I already got my answer.
Jan 22 '08 #3

Post your reply

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