Select Multiple value from Listbox in MS Access

B

billy_pit

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.
 
K

Klatuu

To select multiple items in a list box, set the Multi Select property to
Simple or Extended (I prefer Extended).

To create your list, I assume you mean you want to filter the list based on
the selections made in the list box. Here is an example I use to build a
Where string for filtering reports.

Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim ctl As Control

Set ctl = Me.Controls(strControl)

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhere = ""
Case 1 'Only One Selected
strWhere = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhere = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhere = strWhere & "'" & .ItemData(varItem) & "', "
Next varItem
End With
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
End Select

BuildWhereCondition = strWhere

End Function
 
B

billy_pit

I don't get it bcz i am not much proffesional programmer.
can u plz give me simple code by taking any example in which u can
select multiple items from one listbox and generate list for another
listbox.?
like u have listboxes 1st(CustomerID),2nd(PalletNo),3rd(PONo)
so when u select multiple items from (CustomerID)then it will generate
list for (PalletNo)

as i given in example in my question
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


can u give me code for this example simply plz.
 
K

Klatuu

Sorry, billy_pit, I can't write the code for you. I am happy to provide
examples and advice, but I can't write your code for you. Even if I did,
there is no guarantee it will work correctly without the environment to test
it. And, I do have my own work to get done.

If you need professional assistance, I am sure you will be able to find a
competent developer to do this for you.

Best of Luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top