K
Kari
I am trying to keep track of which records have been printed. I have added a
yes/no field to my table, and have an update query that sets the field to
“yes†after printing. I then added code to look for old, unprinted records
(sometimes the paperwork gets held up overseas and the record is added late).
So far, so good.
At this point what I would like to do is to open the report with the old
records (each report covers a week of data) and ask the user if they want to
print it. Since you cannot open multiple instances of a report reliably (as
per Allen Browne elsewhere on these boards), I need each report to open, then
the dialog (“Do you want to print this report?â€) to open. What is happening
is that the report is not visible when the dialog opens, and does not become
visible until the last dialog is closed (for testing I have about 10 weeks of
old data, therefore 10 separate reports, each with a dialog box). I have
tried Repainting, Setting Focus, Maximizing and Selecting the Report
(DoCmd.SelectObject) after opening, but nothing works.
I have run out of ideas, and I can’t find anything on the boards that is
similar.
Any help, including a different approach, would be most appreciated!
I am using Access 2007 on WIndows XP
Details follow (slightly simplified code):
The following code is behind the OnCLick event of a button on a form used to
select the date:
--------------------
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
Dim Response2 As Single
'Open recordset of "old" shipped orders that have not been printed:
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("Ship Last Week Old Samples Weeks Query")
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
Do While Not rst.EOF
OpenReportToWeekShipped (rst![WeekShipped])
Response2 = MsgBox("Print Report?", vbYesNo) 'if this is put
directly in the "IF" statment it always returns a 0
If Response2 = vbYes Then 'print report
DoCmd.PrintOut acPrintAll
End If 'if report is to be printed
rst.MoveNext
Loop 'if not rst.EOF
Function OpenReportToWeekShipped(dtWeekToPrint As Date)
Dim stWhereClause
stWhereClause = "[WeekShipped] = #" & dtWeekToPrint & "#"
On Error Resume Next 'If the OpenReport action is cancelled (due
to no data) an error is generated
DoCmd.OpenReport "Ship Last Week Samples Report", acViewReport, ,
stWhereClause
End Function
yes/no field to my table, and have an update query that sets the field to
“yes†after printing. I then added code to look for old, unprinted records
(sometimes the paperwork gets held up overseas and the record is added late).
So far, so good.
At this point what I would like to do is to open the report with the old
records (each report covers a week of data) and ask the user if they want to
print it. Since you cannot open multiple instances of a report reliably (as
per Allen Browne elsewhere on these boards), I need each report to open, then
the dialog (“Do you want to print this report?â€) to open. What is happening
is that the report is not visible when the dialog opens, and does not become
visible until the last dialog is closed (for testing I have about 10 weeks of
old data, therefore 10 separate reports, each with a dialog box). I have
tried Repainting, Setting Focus, Maximizing and Selecting the Report
(DoCmd.SelectObject) after opening, but nothing works.
I have run out of ideas, and I can’t find anything on the boards that is
similar.
Any help, including a different approach, would be most appreciated!
I am using Access 2007 on WIndows XP
Details follow (slightly simplified code):
The following code is behind the OnCLick event of a button on a form used to
select the date:
--------------------
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
Dim Response2 As Single
'Open recordset of "old" shipped orders that have not been printed:
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("Ship Last Week Old Samples Weeks Query")
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
Do While Not rst.EOF
OpenReportToWeekShipped (rst![WeekShipped])
Response2 = MsgBox("Print Report?", vbYesNo) 'if this is put
directly in the "IF" statment it always returns a 0
If Response2 = vbYes Then 'print report
DoCmd.PrintOut acPrintAll
End If 'if report is to be printed
rst.MoveNext
Loop 'if not rst.EOF
Function OpenReportToWeekShipped(dtWeekToPrint As Date)
Dim stWhereClause
stWhereClause = "[WeekShipped] = #" & dtWeekToPrint & "#"
On Error Resume Next 'If the OpenReport action is cancelled (due
to no data) an error is generated
DoCmd.OpenReport "Ship Last Week Samples Report", acViewReport, ,
stWhereClause
End Function