W
Walter
I am trying to pass a variant array to the where clause of
the OpenReport method.
When I run example 1 below I get the error message 'Data
type mismatch in criteria expression'.
However if I hardcode the value as a string (Ex 2) it
works, however its not quite what I'm after as I would
like nm to iterate through the array.
Anyone have any ideas.
Regards,
Walter
Ex 1
Option Compare Database
Sub Run_Daily_Sales_Reports()
nm = Array("000939", "000920")
For Each aa In nm
DoCmd.OpenReport "DailySales_Report",
acPreview, "", "[DailySales_Report]![BuyingGroupCode]=" &
aa
DoCmd.OutputTo
acReport, "DailySales_Report", "SnapshotFormat
(*.snp)", "K:\Market\Forecast\Reports\MTD Sales " & aa
& ".snp", False, ""
DoCmd.Close acReport, "DailySales_Report"
Next aa
End Sub
Ex 2
Option Compare Database
Sub Run_Daily_Sales_Reports()
nm = Array("000939", "000920")
For Each aa In nm
DoCmd.OpenReport "DailySales_Report",
acPreview, "", "[DailySales_Report]![BuyingGroupCode]
=""000939"""
DoCmd.OutputTo
acReport, "DailySales_Report", "SnapshotFormat
(*.snp)", "K:\Market\Forecast\Reports\MTD Sales " & aa
& ".snp", False, ""
DoCmd.Close acReport, "DailySales_Report"
Next aa
End Sub
the OpenReport method.
When I run example 1 below I get the error message 'Data
type mismatch in criteria expression'.
However if I hardcode the value as a string (Ex 2) it
works, however its not quite what I'm after as I would
like nm to iterate through the array.
Anyone have any ideas.
Regards,
Walter
Ex 1
Option Compare Database
Sub Run_Daily_Sales_Reports()
nm = Array("000939", "000920")
For Each aa In nm
DoCmd.OpenReport "DailySales_Report",
acPreview, "", "[DailySales_Report]![BuyingGroupCode]=" &
aa
DoCmd.OutputTo
acReport, "DailySales_Report", "SnapshotFormat
(*.snp)", "K:\Market\Forecast\Reports\MTD Sales " & aa
& ".snp", False, ""
DoCmd.Close acReport, "DailySales_Report"
Next aa
End Sub
Ex 2
Option Compare Database
Sub Run_Daily_Sales_Reports()
nm = Array("000939", "000920")
For Each aa In nm
DoCmd.OpenReport "DailySales_Report",
acPreview, "", "[DailySales_Report]![BuyingGroupCode]
=""000939"""
DoCmd.OutputTo
acReport, "DailySales_Report", "SnapshotFormat
(*.snp)", "K:\Market\Forecast\Reports\MTD Sales " & aa
& ".snp", False, ""
DoCmd.Close acReport, "DailySales_Report"
Next aa
End Sub