I would start by creating some code that loops through an DAO recordset and simply debug.print the Person Nm field. Once you have this loop working then you add some additional code that does a little more.
Dim rs as DAO.RecordSet
Dim db as DAO.Database
Dim strSQL as String
Set db = Currentdb
strSQL = "SELECT DISTINCT PersonNm FROM tblTUFMemoForOwnerReimbursedCellPhone"
Set rs = db.CreateRecordset(strSQL)
With rs.
.MoveFirst
Do Until .Eof
Debug.Print .Fields("PersonNm")
.MoveNext
Loop
.Close
End With
Set rs = Nothing
Set db = Nothing
I would take the record source query behind the report and change its SQL property to match the PersonNm field.
---
Do Until .Eof
Debug.Print .Fields("PersonNm")
db.QueryDefs("YourReportRecordSource").SQL = "SELECT * FROM SomeTable WHERE PersonNum = " & .Fields("PersonNm")
.MoveNext
Loop
---
Finally add a line of code that sends your report to pdf after the line that sets the SQL of the querydef.
Duane Hookom MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: luvmymelody@yahoo.com
Date: Wed, 23 Apr 2014 14:56:42 -0700
Subject: [MS_AccessPros] Export Report to pdf
Hello all,
I have a report that I would like to export to a folder. The source of the report is a table and I would like the do loop to export a separate report for each person in the Person Nm field. I have spent 2 days researching code that could do this and nothing is working.
Is there some generic code that could perform this action?
The table name is tblTUFMemoForOwnerReimbursedCellPhone
The fields are Person Nm, Goal Bal, Dept Ld
The Report name is memo report
Thank You
Jim Wagner
Dim rs as DAO.RecordSet
Dim db as DAO.Database
Dim strSQL as String
Set db = Currentdb
strSQL = "SELECT DISTINCT PersonNm FROM tblTUFMemoForOwnerReimbursedCellPhone"
Set rs = db.CreateRecordset(strSQL)
With rs.
.MoveFirst
Do Until .Eof
Debug.Print .Fields("PersonNm")
.MoveNext
Loop
.Close
End With
Set rs = Nothing
Set db = Nothing
I would take the record source query behind the report and change its SQL property to match the PersonNm field.
---
Do Until .Eof
Debug.Print .Fields("PersonNm")
db.QueryDefs("YourReportRecordSource").SQL = "SELECT * FROM SomeTable WHERE PersonNum = " & .Fields("PersonNm")
.MoveNext
Loop
---
Finally add a line of code that sends your report to pdf after the line that sets the SQL of the querydef.
Duane Hookom MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: luvmymelody@yahoo.com
Date: Wed, 23 Apr 2014 14:56:42 -0700
Subject: [MS_AccessPros] Export Report to pdf
Hello all,
I have a report that I would like to export to a folder. The source of the report is a table and I would like the do loop to export a separate report for each person in the Person Nm field. I have spent 2 days researching code that could do this and nothing is working.
Is there some generic code that could perform this action?
The table name is tblTUFMemoForOwnerReimbursedCellPhone
The fields are Person Nm, Goal Bal, Dept Ld
The Report name is memo report
Thank You
Jim Wagner
__._,_.___
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (2) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar