G
Guest
Can anyone help with the following code. I think my code is halting on the
myVarArr(k) if the variable type is not compatible. But I dont know how to
fix it. I took it from another macro I wrote previously which works fine.
Bruce
Function saveGeneralPricelists()
Dim b As Variant
Dim myVarArr(1 To 2)
Dim myVar
ReDim myVar(1 To 2)
DoCmd.SetWarnings False
a = "rpt_PL_General"
myVar = Array("F", "R")
myVarArr(1) = Array("Food Service")
myVarArr(2) = Array("Retail")
myCountry = Array(100, 200, 300, 1000, 1100, 1200, 1300, 1500, 1600, 1700)
k = 1
For Each b In myVar
For Each c In myCountry
DoCmd.OpenReport a, acPreview, "", "[PLT_ID]=""" & b & """
And [CountryID]=" & c
DoCmd.OutputTo acReport, "", "SnapshotFormat(*.snp)",
CurrentProject.Path & "\Pricelists\" & myVarArr(k) & "\" & c & ".snp", False,
""
DoCmd.Close acReport, "rpt_PL_General"
DoCmd.SetWarnings True
Next c
k = k + 1
Next b
DoCmd.SetWarnings True
End Function
myVarArr(k) if the variable type is not compatible. But I dont know how to
fix it. I took it from another macro I wrote previously which works fine.
Bruce
Function saveGeneralPricelists()
Dim b As Variant
Dim myVarArr(1 To 2)
Dim myVar
ReDim myVar(1 To 2)
DoCmd.SetWarnings False
a = "rpt_PL_General"
myVar = Array("F", "R")
myVarArr(1) = Array("Food Service")
myVarArr(2) = Array("Retail")
myCountry = Array(100, 200, 300, 1000, 1100, 1200, 1300, 1500, 1600, 1700)
k = 1
For Each b In myVar
For Each c In myCountry
DoCmd.OpenReport a, acPreview, "", "[PLT_ID]=""" & b & """
And [CountryID]=" & c
DoCmd.OutputTo acReport, "", "SnapshotFormat(*.snp)",
CurrentProject.Path & "\Pricelists\" & myVarArr(k) & "\" & c & ".snp", False,
""
DoCmd.Close acReport, "rpt_PL_General"
DoCmd.SetWarnings True
Next c
k = k + 1
Next b
DoCmd.SetWarnings True
End Function