Stepping through a record set

  • Thread starter Thread starter Jacinda
  • Start date Start date
J

Jacinda

Q: I need to print a batch of "shopcopy" forms, and I need it to group them
by order number... some orders have 1 shopcopy and others may have 5, etc.

When I use the code below, it opens all of the shopcopy forms instead of
walking through the recordset order number by order number....

what am I missing?

my filter on my form is strWhereShop.

Function Shopcopy()
Dim dbsallinonenew As DAO.Database
Dim rstShopcopy As DAO.Recordset

Set dbsallinonenew = currentdb()
Set rstShopcopy = dbsallinonenew.OpenRecordset("Qshopopen", _
dbOpenDynaset)

If MsgBox("Do you want to Print Production Shopcopys?", 4) = 6 Then
With rstShopcopy
Do Until .EOF
'Create the report Filter
'used by the Report_Open event.

strWhereShop = "[ID_ORD]= " & ![ID_ORD]

DoCmd.OpenReport "rshoptoday", acViewPreview

.MoveNext
Loop
End With
End If

rstShopcopy.close

End Function
 
strWhereShop = "[ID_ORD]= " & ![ID_ORD]

Where are these values coming from? try explicitly referencing the value

strWhereShop = "[ID_ORD] = " & rstShopCopy.Fields("ID_ORD")


--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
Jacinda,

You need to add the criteria to the end of your OpenReport method.


docmd.OpenReport "reportname", acViewPreview,,strWhereShop

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
or do that...

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain


Dale Fye said:
Jacinda,

You need to add the criteria to the end of your OpenReport method.


docmd.OpenReport "reportname", acViewPreview,,strWhereShop

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Jacinda said:
Q: I need to print a batch of "shopcopy" forms, and I need it to group them
by order number... some orders have 1 shopcopy and others may have 5, etc.

When I use the code below, it opens all of the shopcopy forms instead of
walking through the recordset order number by order number....

what am I missing?

my filter on my form is strWhereShop.

Function Shopcopy()
Dim dbsallinonenew As DAO.Database
Dim rstShopcopy As DAO.Recordset

Set dbsallinonenew = currentdb()
Set rstShopcopy = dbsallinonenew.OpenRecordset("Qshopopen", _
dbOpenDynaset)

If MsgBox("Do you want to Print Production Shopcopys?", 4) = 6 Then
With rstShopcopy
Do Until .EOF
'Create the report Filter
'used by the Report_Open event.

strWhereShop = "[ID_ORD]= " & ![ID_ORD]

DoCmd.OpenReport "rshoptoday", acViewPreview

.MoveNext
Loop
End With
End If

rstShopcopy.close

End Function
 
That solved the problem... we always seem to miss the obvious...

I ran into one more issue... now it will open the record set for the first
order, but after I print or close the window it ends the code... should I
have it go straight to the printer in order for it to keep stepping through?
--
-Jacinda


Dale Fye said:
Jacinda,

You need to add the criteria to the end of your OpenReport method.


docmd.OpenReport "reportname", acViewPreview,,strWhereShop

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Jacinda said:
Q: I need to print a batch of "shopcopy" forms, and I need it to group them
by order number... some orders have 1 shopcopy and others may have 5, etc.

When I use the code below, it opens all of the shopcopy forms instead of
walking through the recordset order number by order number....

what am I missing?

my filter on my form is strWhereShop.

Function Shopcopy()
Dim dbsallinonenew As DAO.Database
Dim rstShopcopy As DAO.Recordset

Set dbsallinonenew = currentdb()
Set rstShopcopy = dbsallinonenew.OpenRecordset("Qshopopen", _
dbOpenDynaset)

If MsgBox("Do you want to Print Production Shopcopys?", 4) = 6 Then
With rstShopcopy
Do Until .EOF
'Create the report Filter
'used by the Report_Open event.

strWhereShop = "[ID_ORD]= " & ![ID_ORD]

DoCmd.OpenReport "rshoptoday", acViewPreview

.MoveNext
Loop
End With
End If

rstShopcopy.close

End Function
 
I thought about that as I was writing my first post, but was not sure
whether opening in preview mode, without setting the WindowMode of the
OpenReport method to acDialog, would cause a problem or not. Actually, what
I thought you would get is multiple reports opened on your desktop.

The real question is do you want to sit there, and print each report from
the Preview, or just let it print all of the reports. If you aren't doing
too many, and want to review them before printing, I would first try adding
"acDialog" as the last parameter of the OpenReport method. However, if you
are printing lots of these at a time, and you are pretty sure they will come
out the way you want them to, then I'd send them directly to the printer.
Another option would be to put a checkbox with a label (Preview before
print) on your form that opens the report. Then test to see whether it is
checked or not and if it is, use the acViewPreview, if not, use
acViewNormal.

HTH
Dale

Jacinda said:
That solved the problem... we always seem to miss the obvious...

I ran into one more issue... now it will open the record set for the first
order, but after I print or close the window it ends the code... should I
have it go straight to the printer in order for it to keep stepping
through?
--
-Jacinda


Dale Fye said:
Jacinda,

You need to add the criteria to the end of your OpenReport method.


docmd.OpenReport "reportname", acViewPreview,,strWhereShop

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Jacinda said:
Q: I need to print a batch of "shopcopy" forms, and I need it to group
them
by order number... some orders have 1 shopcopy and others may have 5,
etc.

When I use the code below, it opens all of the shopcopy forms instead
of
walking through the recordset order number by order number....

what am I missing?

my filter on my form is strWhereShop.

Function Shopcopy()
Dim dbsallinonenew As DAO.Database
Dim rstShopcopy As DAO.Recordset

Set dbsallinonenew = currentdb()
Set rstShopcopy = dbsallinonenew.OpenRecordset("Qshopopen", _
dbOpenDynaset)

If MsgBox("Do you want to Print Production Shopcopys?", 4) = 6 Then
With rstShopcopy
Do Until .EOF
'Create the report Filter
'used by the Report_Open event.

strWhereShop = "[ID_ORD]= " & ![ID_ORD]

DoCmd.OpenReport "rshoptoday", acViewPreview

.MoveNext
Loop
End With
End If

rstShopcopy.close

End Function
 
Right on the Money!


Thanks ! :-)
--
-Jacinda


Dale Fye said:
I thought about that as I was writing my first post, but was not sure
whether opening in preview mode, without setting the WindowMode of the
OpenReport method to acDialog, would cause a problem or not. Actually, what
I thought you would get is multiple reports opened on your desktop.

The real question is do you want to sit there, and print each report from
the Preview, or just let it print all of the reports. If you aren't doing
too many, and want to review them before printing, I would first try adding
"acDialog" as the last parameter of the OpenReport method. However, if you
are printing lots of these at a time, and you are pretty sure they will come
out the way you want them to, then I'd send them directly to the printer.
Another option would be to put a checkbox with a label (Preview before
print) on your form that opens the report. Then test to see whether it is
checked or not and if it is, use the acViewPreview, if not, use
acViewNormal.

HTH
Dale

Jacinda said:
That solved the problem... we always seem to miss the obvious...

I ran into one more issue... now it will open the record set for the first
order, but after I print or close the window it ends the code... should I
have it go straight to the printer in order for it to keep stepping
through?
--
-Jacinda


Dale Fye said:
Jacinda,

You need to add the criteria to the end of your OpenReport method.


docmd.OpenReport "reportname", acViewPreview,,strWhereShop

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

Q: I need to print a batch of "shopcopy" forms, and I need it to group
them
by order number... some orders have 1 shopcopy and others may have 5,
etc.

When I use the code below, it opens all of the shopcopy forms instead
of
walking through the recordset order number by order number....

what am I missing?

my filter on my form is strWhereShop.

Function Shopcopy()
Dim dbsallinonenew As DAO.Database
Dim rstShopcopy As DAO.Recordset

Set dbsallinonenew = currentdb()
Set rstShopcopy = dbsallinonenew.OpenRecordset("Qshopopen", _
dbOpenDynaset)

If MsgBox("Do you want to Print Production Shopcopys?", 4) = 6 Then
With rstShopcopy
Do Until .EOF
'Create the report Filter
'used by the Report_Open event.

strWhereShop = "[ID_ORD]= " & ![ID_ORD]

DoCmd.OpenReport "rshoptoday", acViewPreview

.MoveNext
Loop
End With
End If

rstShopcopy.close

End Function
 
Back
Top