Peter Bellamy
Registered User.
- Local time
- Today, 23:07
- Joined
- Dec 3, 2005
- Messages
- 295
This is related to an earlier post I made, but I have now moved on to the printing stage.
To recap
I have Price lists for 10 products for 6 customers whch are usually printed in sets, a couple of times a year, The reports are all the same differing only by the customer, their discount and the product. 60 reports with 60 underlying queries each 'set' actioned by a Macro.
It all works but seemed a lot of code and takes a lot of space.
I have now written some vba and SQL that builds a query with the variables and loops around the 10 products each time creating a table for a 'template' report to be based on.
This works fine until it gets to the Open Report stage, reusing the table and template report seems to be the issue
The first product price list previews but the code does not pause to allow printing and closing of that report.
If I put a breakpoint at the OpenReport line it can all be made to work.
How can I introduce a pause to allow the choice of the printer or to discard the current report, close it and allow the next to be built?
Cheers
To recap
I have Price lists for 10 products for 6 customers whch are usually printed in sets, a couple of times a year, The reports are all the same differing only by the customer, their discount and the product. 60 reports with 60 underlying queries each 'set' actioned by a Macro.
It all works but seemed a lot of code and takes a lot of space.
I have now written some vba and SQL that builds a query with the variables and loops around the 10 products each time creating a table for a 'template' report to be based on.
This works fine until it gets to the Open Report stage, reusing the table and template report seems to be the issue
The first product price list previews but the code does not pause to allow printing and closing of that report.
If I put a breakpoint at the OpenReport line it can all be made to work.
How can I introduce a pause to allow the choice of the printer or to discard the current report, close it and allow the next to be built?
Cheers
Code:
For i = 1 To 9
Select Case i
Case 1
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 30"
Str2 = " [41 555 02]"
Str3 = "Warmworld HE30 [41 555 04]"
Str4 = "Servowarm Elite HE 30 [41 555 07]"
Case 2
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 40"
Str2 = " [41 555 03]"
Str3 = "Warmworld HE40 [41 555 05]"
Str4 = "Servowarm Elite HE 40 [41 555 08]"
Case 3
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 50"
Str2 = " [41 555 01]"
Str3 = "Warmworld HE50 [41 555 06]"
Str4 = "Servowarm Elite HE 50 [41 555 09]"
Case 4
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 70"
Str2 = ""
Str3 = "Warmworld HE70"
Str4 = ""
Case 5
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 70/80"
Str2 = " [41 555 10]"
Str3 = "Warmworld HE Combi [41 555 011"
Str4 = "Servowarm Elite HE Combi [41 555 12]"
Case 6
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern Combi"
Str2 = " [47 555 02]"
Str3 = "Warmworld HE30 [47 555 03]"
Str4 = "Servowarm Elite HE 30 [47 555 04]"
Case 7
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 1020"
Str2 = " [41 555 17]"
Str3 = "Warmworld FFC 35/60 [41 555 15]"
Str4 = "Servowarm Elite 21 Plus [41 555 13]"
Case 8
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern 2026"
Str2 = " [41 555 18/19]"
Str3 = "Warmworld FFC 65/80 [41 555 16/21]"
Str4 = "Servowarm Elite 21 [41 555 14]"
Case 9
QrySQL = "DELETE * FROM [Price List Data];"
DoCmd.RunSQL QrySQL
Str1 = "Malvern Dbi Combi"
Str2 = " [47 555 01/05]"
Str3 = "Warmworld FFC Combi [47 555 08/09]"
Str4 = "Servowarm Elite 21 Combi [47 555 06]"
End Select
QrySQL = "INSERT INTO [Price List Data] IN 'z:\Database\2000\Service2k.mdb' " & _
"SELECT Parts.parts_no, Parts.parts_name, Parts.parts_cost, Parts.parts_packaging, Parts.parts_carriage, Parts.parts_price1, Parts.parts_price2, Parts.parts_price3, Parts.parts_price4, ' " & Str1 & Str2 & "' AS Expr1, '" & Str3 & "' AS Expr2, '" & Str4 & "' AS Expr3, ([parts_price2]+[parts_packaging]+[pandp_value1]) AS Servo1, Parts.parts_inc_date " & _
"FROM Carriage RIGHT JOIN Parts ON Carriage.pandp_index = Parts.parts_carriage " & _
"WHERE (((Parts.parts_cost) > 0) And ((Parts.parts_live) = Yes) And ((Parts.parts_usedon1) ='" & Str1 & "')) Or (((Parts.parts_live) = Yes) And ((Parts.parts_usedon2) ='" & Str1 & "')) Or (((Parts.parts_live) = Yes) And ((Parts.parts_usedon3) ='" & Str1 & "')) Or (((Parts.parts_live) = Yes) And ((Parts.parts_usedon4) ='" & Str1 & "')) " & _
"ORDER BY Parts.parts_no; "
'Debug.Print QrySQL
DoCmd.RunSQL QrySQL
DoCmd.OpenReport "Parts Price List Office", acViewReport
Next