Hi,
I am trying to automate a form to create a pdf file of the form, then move on to the next naqmeno in the db and do the same for it, until the end of the file.
My DoCmd.OutputTo works when I dont have it in the loop. Since I have put it in the loop it gives me Run Time Error 2487 "The object type argument for the action or method is blank or invalid".
Here is my code, can anyone please assist me with this.
Option Compare Database
Private Sub Form_Load()
Dim strFormName As String
Dim strName As String
Dim strPath As String
Dim MyDB As Database
Dim rs As DAO.Recordset
Set MyDB = CurrentDb
Set rs = CurrentDb.OpenRecordset("DebtMasters")
srtFormName = "InvoicesDue"
strName = DLookup("NameNo", "Debtmasters")
strPath = "C:\Test\"
Do While Not rs.EOF
If rs("NameNo") <> "" Then
DoCmd.OutputTo acForm, strFormName, "PDFFormat(*.PDF)", strPath & strName & ".PDF", False, "", 0
End If
rs.MoveNext
Loop
rs.Close
End Sub
Thanks in advance.
I am trying to automate a form to create a pdf file of the form, then move on to the next naqmeno in the db and do the same for it, until the end of the file.
My DoCmd.OutputTo works when I dont have it in the loop. Since I have put it in the loop it gives me Run Time Error 2487 "The object type argument for the action or method is blank or invalid".
Here is my code, can anyone please assist me with this.
Option Compare Database
Private Sub Form_Load()
Dim strFormName As String
Dim strName As String
Dim strPath As String
Dim MyDB As Database
Dim rs As DAO.Recordset
Set MyDB = CurrentDb
Set rs = CurrentDb.OpenRecordset("DebtMasters")
srtFormName = "InvoicesDue"
strName = DLookup("NameNo", "Debtmasters")
strPath = "C:\Test\"
Do While Not rs.EOF
If rs("NameNo") <> "" Then
DoCmd.OutputTo acForm, strFormName, "PDFFormat(*.PDF)", strPath & strName & ".PDF", False, "", 0
End If
rs.MoveNext
Loop
rs.Close
End Sub
Thanks in advance.