Got it working with the code below! Yay ME. Ok so I still have one issue though. In LN 23 i have the name of the PDF. Currently it is just the last name of the Marine. I want it to look like LN 11 "RANK & ' ' & LNAME & ', ' & FNAME". Any ideas
Thank you both so much for the help, i am understanding it a little better now.
Sgt B
Code:
Dim db As DAO.Database Dim rs As DAO.Recordset Dim strSQL As String Dim strPath As String Dim strFileName As String Dim strReport As String Dim strCurrentPath As String Dim strmonth As String Dim strPDFNAme As String strPDFNAme = "RANK & ' ' & LNAME & ', ' & FNAME" strmonth = Me.MonthSelect strCurrentPath = Application.CurrentProject.Path strSQL = "SELECT DISTINCT SSN, RANK, LNAME, FNAME FROM [TBLBAND MEMBERS]" strPath = "" & strCurrentPath & "\" & strmonth & " ECR\" strReport = "rptECR" Set db = CurrentDb() Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot) MsgBox strPath With rs If .RecordCount > 0 Then Do Until .EOF strFileName = .Fields!LName & ".pdf" DoCmd.OpenReport strReport, acViewPreview, , "[SSN] = '" & !SSN & "'", acHidden Call DoCmd.OutputTo(objecttype:=acOutputReport, objectname:=strReport, outputformat:=acFormatPDF, outputfile:=strPath & strFileName) DoEvents DoCmd.Close acReport, strReport .MoveNext Loop End If End With rs.Close Set rs = Nothing Set db = Nothing DoCmd.Close acForm, "frmPDFSave"
Sgt B
Comment