D
David Coates
I have a requirement to print out a report for each team leader. I have a
table with the team leaders listed in it, and they are assigned to a number
of tasks in another table. I have developed a report based on the tasks
table and grouped by team leader and that works fine. The problem is though
that there is only one report header page and I want each team leader's
report to be individual with it's own report header page.
I have written the following code which loops through the various team
leaders and runs the query with the criteria referring to 'teamleader()',
unfortunately I keep getting an error message "Run time error 2486 You can't
carry out this action at the present time" when it reaches the line
"DoCmd.OpenView "Print Preview", acViewPreview". The full code involved is:
Function wrkdiary_report()
DoCmd.OpenView "Print Preview", acViewPreview
DoCmd.PrintOut
response = MsgBox("Next Team Leader?", vbOKCancel) ' This is only to
enable me to control the
output until I get the whole code working correctly.
End Function
Function teamleader()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblteam_leader", dbOpenSnapshot)
Do Until rst.EOF
teamleader = rst!Team_Leader
wrkdiary_report
rst.MoveNext
Loop
End Function
I apologise in advance if this is the wrong newsgroup for this. It seemed as
much a report writing issue as a VBA issue.
Look forward to any assistance.
--
Regards,
David Coates
Progen Ltd.
Mobile : 021 685 607
Phone : +64 7 839 3326
Fax : +64 7 839 3327
CONFIDENTIALITY : This e-mail and any attachments are confidential and
may be privileged. If you are not a named recipient, please notify the
sender immediately and do not disclose the contents to another person, use
it for any purpose or store or copy the information in any medium.
table with the team leaders listed in it, and they are assigned to a number
of tasks in another table. I have developed a report based on the tasks
table and grouped by team leader and that works fine. The problem is though
that there is only one report header page and I want each team leader's
report to be individual with it's own report header page.
I have written the following code which loops through the various team
leaders and runs the query with the criteria referring to 'teamleader()',
unfortunately I keep getting an error message "Run time error 2486 You can't
carry out this action at the present time" when it reaches the line
"DoCmd.OpenView "Print Preview", acViewPreview". The full code involved is:
Function wrkdiary_report()
DoCmd.OpenView "Print Preview", acViewPreview
DoCmd.PrintOut
response = MsgBox("Next Team Leader?", vbOKCancel) ' This is only to
enable me to control the
output until I get the whole code working correctly.
End Function
Function teamleader()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblteam_leader", dbOpenSnapshot)
Do Until rst.EOF
teamleader = rst!Team_Leader
wrkdiary_report
rst.MoveNext
Loop
End Function
I apologise in advance if this is the wrong newsgroup for this. It seemed as
much a report writing issue as a VBA issue.
Look forward to any assistance.
--
Regards,
David Coates
Progen Ltd.
Mobile : 021 685 607
Phone : +64 7 839 3326
Fax : +64 7 839 3327
CONFIDENTIALITY : This e-mail and any attachments are confidential and
may be privileged. If you are not a named recipient, please notify the
sender immediately and do not disclose the contents to another person, use
it for any purpose or store or copy the information in any medium.