Passing varaibles from one list field to another

G

Guest

I hope i can explain this clearly enough, I have a database, in which I want
a form with a list box, that looks up active campaigns (thats the easy bit.)
I have another list box which is empty. in the middle of these two text boxes
are 4 buttons.

What i want is, when the user preses the top button it selects all the
variables (active campaigns) from the left hand text box and inputs it to the
right hand text box.

If the user wants to select only a few variables they left click on the
options they want and left click on the second button down. Again this then
moves this data from the left hand list to the right hand list box. The last
two buttons do the same but are reveresed as above.

Have I made sence? can anyone point me in the right directions?

Regards
 
G

Guest

What query are you using to select the Active campaigns, and what do you want
to do once you get them into the right hand listbox?
 
G

Guest

I have some data export functions within the database that I want to call
based on the values in the right hand box. For example if "Devon" is selected
and placed in the right hand box, then when they click on a "Get Data"
button, it looks up the value in the right hand text box and runs the export
function called "qry_DevonDMCExport", which exports all the data into excel.
 
D

Dale Fye

One of the ways I implement this is to modify my table structure to include
an IsSelected (Yes/No) column in the table that populates the list box.

Then I setup my listbox query for the left listbox to select only those
values from the table where IsSelected = False, and the query for the
righthand listbox to include only those values where IsSelected is true.
Something like:

SELECT ID, Description FROM yourTable WHERE IsSelected = False

For your "Select All" button, I would have code similar to:

Private sub cmd_Select_All_Click
currentdb.execute "Update yourTable SET IsSelected = True
me.lst_Unselected.requery
me.lst_Selected.requery
End Sub

and for the Select highlighted button:

Private sub cmd_Select_Highlighted_Click

Dim varItem as variant
for each varItem in me.lst_Unselected.ItemsSelected
currentdb.execute "Update yourTable " _
& "Set IsSelected = True " _
& "WHERE ID = " &
me.lst_Unselected.column(0, varItem)
next
me.lst_Unselected.requery
me.lst_Selected.requery
End Sub

Just reverse these procedures for the other 2 buttons.

HTH
Dale
 

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