Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Select List Box

Status
Not open for further replies.

MAPetry

Technical User
Aug 2, 2000
43
0
0
US
I have a database form where I want user to enter:
1.Project (lookup on Project table)
2.Division (lokup on Division table)
List box displays query of companies where criteria is division input above.
What I need is:
1.)a command to copy the selected companies in list box 1 to another list box.
2.)after selecting all the companies you want. a command to save as new record in table having Project.Division.Company.

I have a form similar but it is based on a table with fairly constant data and I added a selected column and based second list box on selected (yes/No) of first table and that works fine but since my list box here is based on a query I am at a loss. Any way I can save data from query as table for selection? Or work command for copying selected companies differently?

Any Help will be appreciated
Mary Ann
 
You need more than just a command, you need quite a bit of code. It needs to:

1) Fill listbox1 with all the fields you need to copy to listbox2.
2) Read the column values from listbox1 and create a text string of the rows for listbox2. There are delimites for columns and rows. I believe it is , and ;.
3) Append the string to the ControlSource property on listbox2.
4) Caution: If the value is already in listbox2 then your code should be smart enough to recognize that and provide the user with an information message.
5) Make sure your columns property for the listboxes are set the same.


Note: This is just a quick sample of what needs to happen.

Dim intCols As Integer
Dim intCnt As Integer
Dim strCopy As String

intCols = listbox1.Columns
For intCtr = 0 To Listbox1.Columns - 1
strCopy = strCopy & listbox1.Column(intCtr).Value & ","
Next intCtr
'Row delimiter
strCopy = strCopy & ";"
listbox2.ControlSource = listbox2.ControlSource & strCopy



Steve King Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top