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

Exporting a list box in Access

Status
Not open for further replies.

Tript99

Programmer
Dec 4, 2001
13
US
Hello,
I was wondering if anyone knew if it was possible to export the contents of a listbox (in Access 97 form) to an excel spreadsheet. I've been trying to use this code but have been unsuccessful so far..

Private Sub cmdExport_Click()
DoCmd.OutputTo acOutputObject, "lstTest", acFormatXLS, , False
End Sub

Any help would be great!
Tript.
 
Hi Tript!

If the rowsource of the list box is a query you can use the output to command:

DoCmd.OutputTo acOutputQuery, lstTest.RowSource, acFormatXLS, , False

If it is an SQL statement, you may be able to create a querydef first and then use the output to command like it is above. Barring that, you should be able to recreate the rowsource programmatically and create a query that you can then export.

hth Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top