Print oreview multiple records

  • Thread starter Thread starter Reggie
  • Start date Start date
R

Reggie

Hi and TIA. I have a form where the user can select multiple records that
they want printed. When they clcik print I would like the preview window to
open for the first record so they can view it and or change printer options.
Once done and they close the report I would like it to automaticly move to
the next record and open the preview window again and continue till the end
of the recordset. If I dont preview the records and send them directly to
the printer they all print seperatly and it works fine, however when I use
the preview method my code simply loops thru to the last record then opens
the preview window. What I'm doing is setting a global variable for the ID
of the current record and my queries that calculate the values for my report
then retrieve the variable. Below is what I'm trying. The other reason I
have to do this is because some values in my group header are calculated on
the fly for each record so I must iterate throught the record, calculate and
print, then move to the next etc. Any advice would be apprecited. Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If
 
Reggie said:
Hi and TIA. I have a form where the user can select multiple records that
they want printed. When they clcik print I would like the preview window to
open for the first record so they can view it and or change printer options.
Once done and they close the report I would like it to automaticly move to
the next record and open the preview window again and continue till the end
of the recordset. If I dont preview the records and send them directly to
the printer they all print seperatly and it works fine, however when I use
the preview method my code simply loops thru to the last record then opens
the preview window. What I'm doing is setting a global variable for the ID
of the current record and my queries that calculate the values for my report
then retrieve the variable. Below is what I'm trying. The other reason I
have to do this is because some values in my group header are calculated on
the fly for each record so I must iterate throught the record, calculate and
print, then move to the next etc. Any advice would be apprecited. Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog
 
Marshall Barton said:
Reggie said:
Hi and TIA. I have a form where the user can select multiple records that
they want printed. When they clcik print I would like the preview window
to
open for the first record so they can view it and or change printer
options.
Once done and they close the report I would like it to automaticly move to
the next record and open the preview window again and continue till the
end
of the recordset. If I dont preview the records and send them directly to
the printer they all print seperatly and it works fine, however when I use
the preview method my code simply loops thru to the last record then opens
the preview window. What I'm doing is setting a global variable for the
ID
of the current record and my queries that calculate the values for my
report
then retrieve the variable. Below is what I'm trying. The other reason I
have to do this is because some values in my group header are calculated
on
the fly for each record so I must iterate throught the record, calculate
and
print, then move to the next etc. Any advice would be apprecited. Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog

Marsh, Thanks for the reply and that worked with the exception of my
toolbars not showing when I do this so the user would have to know to right
click the report in order to print the report. Any ideas?
 
Reggie said:
Reggie said:
Hi and TIA. I have a form where the user can select multiple records that
they want printed. When they clcik print I would like the preview window
to
open for the first record so they can view it and or change printer
options.
Once done and they close the report I would like it to automaticly move to
the next record and open the preview window again and continue till the
end
of the recordset. If I dont preview the records and send them directly to
the printer they all print seperatly and it works fine, however when I use
the preview method my code simply loops thru to the last record then opens
the preview window. What I'm doing is setting a global variable for the
ID
of the current record and my queries that calculate the values for my
report
then retrieve the variable. Below is what I'm trying. The other reason I
have to do this is because some values in my group header are calculated
on
the fly for each record so I must iterate throught the record, calculate
and
print, then move to the next etc. Any advice would be apprecited. Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog

Marsh, Thanks for the reply and that worked with the exception of my
toolbars not showing when I do this so the user would have to know to right
click the report in order to print the report.


Ick. I've not run into that one before.

Do you have the report's Toolbar property set to the name of
your toolbar?
 
Marshall Barton said:
Reggie said:
Reggie wrote:

Hi and TIA. I have a form where the user can select multiple records
that
they want printed. When they clcik print I would like the preview
window
to
open for the first record so they can view it and or change printer
options.
Once done and they close the report I would like it to automaticly move
to
the next record and open the preview window again and continue till the
end
of the recordset. If I dont preview the records and send them directly
to
the printer they all print seperatly and it works fine, however when I
use
the preview method my code simply loops thru to the last record then
opens
the preview window. What I'm doing is setting a global variable for the
ID
of the current record and my queries that calculate the values for my
report
then retrieve the variable. Below is what I'm trying. The other reason
I
have to do this is because some values in my group header are calculated
on
the fly for each record so I must iterate throught the record, calculate
and
print, then move to the next etc. Any advice would be apprecited.
Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog

Marsh, Thanks for the reply and that worked with the exception of my
toolbars not showing when I do this so the user would have to know to
right
click the report in order to print the report.


Ick. I've not run into that one before.

Do you have the report's Toolbar property set to the name of
your toolbar?

Marsh, Yes I do have the toolbar property set to my toolbar name and it
works when doing a normal preview, but not when I use the open as dialog
argument.
 
Reggie said:
"Marshall Barton"wrote
Reggie said:
Reggie wrote:

Hi and TIA. I have a form where the user can select multiple records
that
they want printed. When they clcik print I would like the preview
window
to
open for the first record so they can view it and or change printer
options.
Once done and they close the report I would like it to automaticly move
to
the next record and open the preview window again and continue till the
end
of the recordset. If I dont preview the records and send them directly
to
the printer they all print seperatly and it works fine, however when I
use
the preview method my code simply loops thru to the last record then
opens
the preview window. What I'm doing is setting a global variable for the
ID
of the current record and my queries that calculate the values for my
report
then retrieve the variable. Below is what I'm trying. The other reason
I
have to do this is because some values in my group header are calculated
on
the fly for each record so I must iterate throught the record, calculate
and
print, then move to the next etc. Any advice would be apprecited.
Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog


Marsh, Thanks for the reply and that worked with the exception of my
toolbars not showing when I do this so the user would have to know to
right
click the report in order to print the report.


Ick. I've not run into that one before.

Do you have the report's Toolbar property set to the name of
your toolbar?

Marsh, Yes I do have the toolbar property set to my toolbar name and it
works when doing a normal preview, but not when I use the open as dialog
argument.


It might be awhile until I can find time to investigate this
so I hope someone that has run into it jumps in with an
explanation.

In the meantime, you could try a truly hokey workaround of
using a code loop instead of dialog mode;

DoCmd.OpenReport stDocName, acViewPreview
With CurrentProject.AllReports(stDocName)
Do Until Not .IsLoaded
DoEvents
Loop
End With
 
Marshall Barton said:
Reggie said:
"Marshall Barton"wrote
Reggie wrote:


Reggie wrote:

Hi and TIA. I have a form where the user can select multiple records
that
they want printed. When they clcik print I would like the preview
window
to
open for the first record so they can view it and or change printer
options.
Once done and they close the report I would like it to automaticly
move
to
the next record and open the preview window again and continue till
the
end
of the recordset. If I dont preview the records and send them
directly
to
the printer they all print seperatly and it works fine, however when I
use
the preview method my code simply loops thru to the last record then
opens
the preview window. What I'm doing is setting a global variable for
the
ID
of the current record and my queries that calculate the values for my
report
then retrieve the variable. Below is what I'm trying. The other
reason
I
have to do this is because some values in my group header are
calculated
on
the fly for each record so I must iterate throught the record,
calculate
and
print, then move to the next etc. Any advice would be apprecited.
Thanks
again

stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If


If you want the code to pause until the preview is closed,
then open the report in dialog mode:

DoCmd.OpenReport stDocName, acViewPreview, _
WindowMode:= acDialog


Marsh, Thanks for the reply and that worked with the exception of my
toolbars not showing when I do this so the user would have to know to
right
click the report in order to print the report.


Ick. I've not run into that one before.

Do you have the report's Toolbar property set to the name of
your toolbar?

Marsh, Yes I do have the toolbar property set to my toolbar name and it
works when doing a normal preview, but not when I use the open as dialog
argument.


It might be awhile until I can find time to investigate this
so I hope someone that has run into it jumps in with an
explanation.

In the meantime, you could try a truly hokey workaround of
using a code loop instead of dialog mode;

DoCmd.OpenReport stDocName, acViewPreview
With CurrentProject.AllReports(stDocName)
Do Until Not .IsLoaded
DoEvents
Loop
End With

No problem Marsh. Thanks for your time
 
Reggie said:
Reggie wrote:
stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If
...you could try ... using a code loop...;

DoCmd.OpenReport stDocName, acViewPreview
With CurrentProject.AllReports(stDocName)
Do Until Not .IsLoaded
DoEvents
Loop
End With


After finally finding some time to seriously think about all
this, I conclude that dialog mode is not such a great idea.
Because dialog/popup forms/reports are not in the Access
MDI, the tool/menu bar stuff is pretty much disconnected
from the form/report.

I don't like using a code loop such as I posted, but if you
can not use a report that outputs all the data in one shot,
then I guess you will have to use the loop to get your
custom toolbar.
 
Marshall Barton said:
Reggie said:
Reggie wrote:
stDocName = "rptReqs_Print"
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryReq_Print", dbOpenDynaset)

If AreThereRecords(rst) Then
rst.MoveFirst
Do Until rst.EOF
plngOSID = rst![OS_ID] 'Current record ID
Call SetOSID(plngOSID) 'Set global variable
Set db2 = CurrentDb()
Set rst2 = db.OpenRecordset(stQuery, dbOpenDynaset)
If AreThereRecords(rst2) Then
DoCmd.OpenReport stDocName, acViewPreview
End If
rst.MoveNext
Loop
End If

...you could try ... using a code loop...;

DoCmd.OpenReport stDocName, acViewPreview
With CurrentProject.AllReports(stDocName)
Do Until Not .IsLoaded
DoEvents
Loop
End With


After finally finding some time to seriously think about all
this, I conclude that dialog mode is not such a great idea.
Because dialog/popup forms/reports are not in the Access
MDI, the tool/menu bar stuff is pretty much disconnected
from the form/report.

I don't like using a code loop such as I posted, but if you
can not use a report that outputs all the data in one shot,
then I guess you will have to use the loop to get your
custom toolbar.

Sounds good and thanks for digging deeper. Appreciate it very much. Take
care!
 
Back
Top