Ok, got my code to work....for the most part... This works, until I try to add acHidden
Code:
Private Sub ExportReports_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyFileName As String
Dim temp As String
Dim sFolder As String
' Open the select folder prompt
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Choose your save location"
.ButtonName = "OK"
If .Show = -1 Then ' if OK is pressed assign folder name to sFolder variable
sFolder = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT ManagerName From qry_STF_Report_Manager_Detail", dbOpenDynaset)
Do While Not rs.EOF
temp = rs("ManagerName")
MyFileName = "STF User Level Access " & rs("ManagerName") & ".PDF"
DoCmd.OpenReport "STFMVS1 User Level Access Report", acViewPreview, , "[ManagerName]='" & temp & "'"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, sFolder & "\" & MyFileName
DoCmd.Close acReport, "STFMVS1 User Level Access Report"
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Sub
The moment I add acHidden here
Code:
DoCmd.OpenReport "STFMVS1 User Level Access Report", acViewPreview, , "[ManagerName]='" & temp & "'", acHidden
I get Run-time error 2487 The object Type argument for the action or method is blank or invalid, it highlights this line
Code:
DoCmd.OutputTo acOutputReport, "", acFormatPDF, sFolder & "\" & MyFileName
Works fine until I add the acHidden option...any ideas?