1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
|
Private Function Print_pick(rpt_name)
'===========================================================================
'This function is called from the picklists button, it will print the picklists
'on the report that it has been sent as rpt_name
'===========================================================================
'======Call functions to prepare the text for the reports====
On Error GoTo Print_pick_Error
Pre_Set_oText
Pre_Set_Text
Pre_Set_iText
'============================================================
Dim db As dao.Database
Dim qdf As dao.QueryDef
Dim StrSQL As String
Dim xOrders, xOrdArry, stdocname
Dim xCheck
' Identify the database and assign it to the variable
Set db = CurrentDb
' Check for the existence of the query, create it if not found,
' and assign it to the variable
If Not QueryExists("pt_rpt_pick_list_std") Then
Set qdf = db.CreateQueryDef("pt_rpt_pick_list_std")
Else
Set qdf = db.QueryDefs("pt_rpt_pick_list_std")
End If
' Need to get the list of orders
xOrders = RTrim(LTrim(Trim(GetOrders)))
xOrdArry = Replace(xOrders, " ;", "','")
'MsgBox xOrdArry
Debug.Print xOrdArry
' Build the SQL string
StrSQL = "SELECT DISTINCT " & _
"TOP 100 PERCENT dbo.tbl_OHeader.DDNAM, dbo.tbl_OHeader.ADAD1, dbo.tbl_OHeader.ADAD2, dbo.tbl_OHeader.ADAD3, dbo.tbl_OHeader.ADAD4, " & _
"dbo.tbl_OHeader.ADPC1, dbo.tbl_OHeader.ADPC2, dbo.tbl_OHeader.DCNAM, dbo.tbl_OHeader.ACAD1, dbo.tbl_OHeader.ACAD2, " & _
"dbo.tbl_OHeader.ACAD3, dbo.tbl_OHeader.ACAD4, dbo.tbl_OHeader.ACPC1, dbo.tbl_OHeader.ACPC2, dbo.tbl_OHeader.BATCH_OI_NO, " & _
"dbo.tbl_OHeader.GRUTE1, dbo.tbl_OHeader.ECSTNC, dbo.tbl_OHeader.EDTNOC, dbo.tbl_OHeader.EORNO, dbo.tbl_OHeader.GORTP, " & _
"dbo.tbl_OLine.LORDS4, dbo.tbl_OLine.ITEM, dbo.tbl_OLine.DITMD, dbo.tbl_OLine.QGWGT, dbo.tbl_OLine.MUDN3, dbo.tbl_OLine.UOMTU, " & _
"dbo.tbl_OHeader.[@SOVD], dbo.tbl_OHeader.DSCRF1, dbo.tbl_OHeader.ESRPP, dbo.tbl_OHeader.ESRPS, dbo.tbl_OLine.QREQB, " & _
"dbo.tbl_OText.DTEXT1 , dbo.tbl_trans.trans_delNo, dbo.tbl_trans.trans_customer, dbo.tbl_trans.trans_loadid, dbo.tbl_trans.trans_value, dbo.tbl_oline.itmrr6, Case When IsNumeric(Left(dbo.tbl_OLine.ITEM + ' ',1)) = 1 Then 1 Else 0 End AS Expr1037, dbo.tbl_OLine.ITEM, 0 AS [£TOVL], dbo.tbl_oHeader.batch_number " & _
"FROM dbo.tbl_OHeader INNER JOIN " & _
"dbo.tbl_OLine ON dbo.tbl_OHeader.BATCH_OI_NO = dbo.tbl_OLine.BATCH_OI_NO LEFT OUTER JOIN " & _
"dbo.tbl_trans ON dbo.tbl_OHeader.BATCH_OI_NO = dbo.tbl_trans.trans_orderno LEFT OUTER JOIN " & _
"dbo.tbl_OText ON dbo.tbl_OLine.BATCH_OI_NO = dbo.tbl_OText.EORNO3 AND dbo.tbl_OLine.LORDS4 = dbo.tbl_OText.LORDS1 " & _
"WHERE (dbo.tbl_OHeader.BATCH_OI_NO IN ('" & xOrdArry & "')) AND (dbo.tbl_trans.trans_loadid = '" & GetLoadNo & "') " & _
"ORDER BY Case When IsNumeric(Left(dbo.tbl_OLine.ITEM + ' ',1)) = 1 Then 1 Else 0 End, dbo.tbl_OLine.ITEM"
'InputBox "", "", strSQL
' Pass the SQL string to the query
qdf.sql = StrSQL
' Turn off screen updating
'DoCmd.Echo False
stdocname = Trim(rpt_name)
'Is Pick Printing enabled?
'Dr Nick friendly :P
'==========================
xCheck = CheckConfig("pick_print_on")
If xCheck = vbTrue Then
DoCmd.SelectObject acReport, stdocname, True
DoCmd.PrintOut acPrintAll, , , , CheckConfig("print_copies_draft_pick")
'DoCmd.OpenReport stdocname, acViewNormal
End If
On Error GoTo 0
Exit Function
Print_pick_Error:
Call ErrorLog(Err.Description, Err.Number, Me.Name, "Print_pick")
'MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Print_pick of VBA Document Form_frm_load_preview"
End Function
|