By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,560 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,560 IT Pros & Developers. It's quick & easy.

Export with a list box

100+
P: 158
I'm trying to figure out how to export based on a list box. here is the code that i have, and for some reason its not working.

Expand|Select|Wrap|Line Numbers
  1. If (lstExport.Selected(1) = vbTrue) Then
  2.     DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblSaveMVROutlets", "C:\Maps_MVRs\Append_Work_Files\Analysis\MVRs_Outlets_Export.xls", True
  3.     MsgBox "Exported", vbOKOnly
  4.     End If
  5. End Sub
Any help would be greatly appreciated
Aug 19 '08 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,669
To efficiently process Selected Items in a List Box, use this code as a Template:
Expand|Select|Wrap|Line Numbers
  1. Dim varItem As Variant
  2.  
  3. With Me![lstExport]
  4.   'Make sure at leats 1 Item is selected
  5.   If .ItemsSelected.Count > 0 Then
  6.     For Each varItem In .ItemsSelected
  7.       'Process entry in the Bound Column
  8.       Debug.Print .Column(0, varItem)
  9.     Next
  10.   Else
  11.     Exit Sub
  12.   End If
  13. End With
Aug 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.