So i have this criterial set in a query that I am looking for export using the
Dim rst
Dim XL As Excel.Application
Set XL = CreateObject("excel.application")
Dim vFile
vFile = "template location"
Set rst = CurrentDb.OpenRecordset("BRequest")
With XL
.Visible = False
.Workbooks.Open vFile
.Sheets("BC").Select
.Range("A4").Select
.ActiveCell.CopyFromRecordset rst
.ActiveWorkbook.SaveAs filename:=("Save file name and location"
.ActiveWorkbook.Close
.Application.Quit
The query runs fine if i run this manually but not from the above i get the runtime error
criteria in query is set as
[Forms]![BRequest]![Account-No]
Dim rst
Dim XL As Excel.Application
Set XL = CreateObject("excel.application")
Dim vFile
vFile = "template location"
Set rst = CurrentDb.OpenRecordset("BRequest")
With XL
.Visible = False
.Workbooks.Open vFile
.Sheets("BC").Select
.Range("A4").Select
.ActiveCell.CopyFromRecordset rst
.ActiveWorkbook.SaveAs filename:=("Save file name and location"
.ActiveWorkbook.Close
.Application.Quit
The query runs fine if i run this manually but not from the above i get the runtime error
criteria in query is set as
[Forms]![BRequest]![Account-No]