Good Afternoon. I am trying to add a command button to a form that will export a list within the form to excel. The form is set up with 4 drop down menus (Region, Job, Sub, and Month) that decide the outcome of the lists. There are 5 lists on the form tied to 5 different queries. After I filter using the drop downs and update the form, I would like to export the results of one of the lists to excel, but I am running into an issue. The code that I am currently using for command button is:
Private Sub Retired_Click()
Dim sXL As String, oXL As Object
sXL = "C:\temp\Retired.xls"
DoCmd.TransferSpreadsheet acExport, , "qryOldAssets", sXL
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
oXL.WorkBooks.Open FileName:=sXL
End Sub
Is there a way to directly add the list name, lstRetired, to the DoCmd?
Do I need to add Me.cboMonth.Value, etc. as query criteria in the DoCmd line?
Let me know if I haven't provided enough info.