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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy a listbox contents to a table

Status
Not open for further replies.

webblaze

Programmer
Aug 1, 2001
3
US
Hi,
This may sound easy but I need to know how to copy the contents of a listbox which is generated by different querys to append to a table. Do I us the copyobject under the DoCmd? If my list box is this Forms![frm_Add_Mod_Menu]!List50.RowSource how do I copy this to a table? Thanks

Dan
 
A lot depends what list50.rowsource is. At what point did you set the source. I would say the easiest way would be to take what ever the last query you ran in "is generated by different querys " and either turn it into an append query or open it as a recordset and add records using VBA.

The other option is using VBA to loop thru each item in the listbox if you can't do the above and need help coding this let me know.
Good Luck
 
I assign the listbox's source like this: List50.RowSource = "my_query" where my_query can be one of the many querys I run. I can turn my query into append querys but want to get away from that because I only want to append a table to print out a report based on the table and not every time. If looping through the records is the easist method of copying the listbox contents into a table then can you show me the code to loop through the listbox? Thanks

Dan
 
If that is all you want to do, in the the reports on open event place code like this

me.recordsource = forms!yourformname!list50.rowsource
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top