Exporting to Excel - Filename

P

pjd33

I have a report that is produced from a combo box on a Form.

I want to be able to setup a command button on the Form to save the results
as an Excel file and use the option from the dropdown menu and the current
date into the filename. At present I can export and enter the date but I
cannot work out how to put the drop down option into the filename.

The combo box is named cboLateListAssetClass

There are 4 options (A, B, C , D) to choose from before the report is run
and if B were selected I would like the filename to read "yyyymmdd B
LateList.xls"

Current code for the command button is:

Private Sub cmdSaveLateList_Click()
DoCmd.OpenQuery "qryLateList", acViewNormal, acEdit
DoCmd.Close acQuery, "qryLateList"

Dim sToday As String
sToday = Format(Date, "yyyymmdd")

DoCmd.OutputTo acReport, "rptLateList", acFormatXLS, "U:\Database\" &
sToday & " LateList.xls", True

End Sub


Many thanks for any help
 
K

Klatuu

You left out the selection from the combo box (A,B,C,D)

sToday = Format(Date, "yyyymmdd") & Me.cboLateListAssetClass
 

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