Voor een simpel access programma heb ik een macro die onder andere doet printen en ook 1 die als pdf het betreffende document opslaat.
Het probleem wat ik echter heb is als ik beide macro's op mijn pc uitvoer doen ze het perfect terwijl ik het op een andere pc doe gaat die alle records na om op te slaan. Op mijn pc heb ik de office 365 versie van access terwijl op de andere pc de access viewer geinstalleerd is.
De opslaan macro is als volgt:
Ik heb voor het makkelijk te houden de macro even geconverteerd naar vb om het leesbaar te krijgen. Ik weet dat de macro beter geschreven kan worden dus aanbevellingen zijn altijd welkom. Weet iemand hoe ik dit kan oplossen?
Het probleem wat ik echter heb is als ik beide macro's op mijn pc uitvoer doen ze het perfect terwijl ik het op een andere pc doe gaat die alle records na om op te slaan. Op mijn pc heb ik de office 365 versie van access terwijl op de andere pc de access viewer geinstalleerd is.
De opslaan macro is als volgt:
code:
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
| Option Compare Database
'------------------------------------------------------------
' mcro_Opslaan
'
'------------------------------------------------------------
Function mcro_Opslaan()
On Error GoTo mcro_Opslaan_Err
With CodeContextObject
On Error Resume Next
If (.Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (.MacroError.Number <> 0) Then
MsgBox .MacroError.Description, vbOKOnly, ""
Exit Function
End If
On Error GoTo 0
If (.Form.Type = "Hoxx_Order") Then
DoCmd.OpenReport "rpt_4_Purchase_Order", acViewPreview, "", "[po_id]=" & Nz(.po_id, 0), acNormal
End If
If (.Form.Type = "Nextdeal_Order") Then
DoCmd.OpenReport "rpt_3_Purchase_Order_ND", acViewPreview, "", "[po_id]=" & Nz(.po_id, 0), acNormal
End If
If (.Form.Type = "Sales_Order") Then
DoCmd.OpenReport "rpt_5_Sales_Order", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Credit_Note") Then
DoCmd.OpenReport "rpt_10_Credit_Note", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Factuur") Then
DoCmd.OpenReport "rpt_6_Sales_Order_NL", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Proforma") Then
DoCmd.OpenReport "rpt_7_Proforma", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Offerte") Then
DoCmd.OpenReport "rpt_2_Proforma_NL", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Packing_Slip") Then
DoCmd.OpenReport "rpt_8_Packing_Slip", acViewPreview, "", "[so_id]=" & Nz(.so_id, 0), acNormal
End If
If (.Form.Type = "Hoxx_Order") Then
DoCmd.OutputTo acOutputReport, "rpt_4_Purchase_Order", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\PO\" & Nz(.po_number, 0) & " " & Nz(.po_supplier, 0) & ".pdf", True, "", 0, acExportQualityPrint
End If
If (.Form.Type = "Nextdeal_Order") Then
DoCmd.OutputTo acOutputReport, "rpt_3_Purchase_Order_ND", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\PO\" & Nz(.po_number, 0) & " " & Nz(.po_supplier, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Sales_Order") Then
DoCmd.OutputTo acOutputReport, "rpt_5_Sales_Order", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\CI\" & Nz(.so_sales_invoice, 0) & " " & Nz(.so_customer, 0) & ".pdf", True, "", 0, acExportQualityPrint
End If
If (.Form.Type = "Credit_Note") Then
DoCmd.OutputTo acOutputReport, "rpt_10_Credit_Note", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\CI\" & Nz(.so_sales_invoice, 0) & " Credit " & Nz(.so_customer, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Factuur") Then
DoCmd.OutputTo acOutputReport, "rpt_6_Sales_Order_NL", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\CI\" & Nz(.so_sales_invoice, 0) & " " & Nz(.so_customer, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Proforma") Then
DoCmd.OutputTo acOutputReport, "rpt_7_Proforma", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\PI\" & Nz(.so_sales_invoice, 0) & " " & Nz(.so_customer, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Offerte") Then
DoCmd.OutputTo acOutputReport, "rpt_2_Proforma_NL", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\PI\" & Nz(.so_sales_invoice, 0) & " " & Nz(.so_customer, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Packing_Slip") Then
DoCmd.OutputTo acOutputReport, "rpt_8_Packing_Slip", "PDFFormat(*.pdf)", "z:\Administratie\" & Nz(.Year, 0) & "\PS\" & Nz(.Packing_Slip, 0) & " " & Nz(.so_customer, 0) & ".pdf", True, "", , acExportQualityPrint
End If
If (.Form.Type = "Hoxx_Order") Then
If (Not IsNull(.po_id)) Then
TempVars.Add "Huidige_id", .po_id
End If
If (IsNull(.po_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[po_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Nextdeal_Order") Then
If (Not IsNull(.po_id)) Then
TempVars.Add "Huidige_id", .po_id
End If
If (IsNull(.po_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[po_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Sales_Order") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Credit_Note") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Factuur") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Proforma") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Offerte") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
If (.Form.Type = "Packing_Slip") Then
If (Not IsNull(.so_id)) Then
TempVars.Add "Huidige_id", .so_id
End If
If (IsNull(.so_id)) Then
TempVars.Add "Huidige_id", Nz(DMax("[so_id]", .Form.RecordSource), 0)
End If
End If
TempVars.Remove "Huidige_id"
DoCmd.Close acReport, "rpt_2_Proforma_NL"
DoCmd.Close acReport, "rpt_3_Purchase_Order_ND"
DoCmd.Close acReport, "rpt_4_Purchase_Order"
DoCmd.Close acReport, "rpt_5_Sales_Order"
DoCmd.Close acReport, "rpt_6_Sales_Order_NL"
DoCmd.Close acReport, "rpt_7_Proforma"
DoCmd.Close acReport, "rpt_8_Packing_Slip"
DoCmd.Close acReport, "rpt_10_Credit_Note"
End With
mcro_Opslaan_Exit:
Exit Function
mcro_Opslaan_Err:
MsgBox Error$
Resume mcro_Opslaan_Exit
End Function |
Ik heb voor het makkelijk te houden de macro even geconverteerd naar vb om het leesbaar te krijgen. Ik weet dat de macro beter geschreven kan worden dus aanbevellingen zijn altijd welkom. Weet iemand hoe ik dit kan oplossen?
-Te huur