Hi All,
Long time reader, first time poster.
I am currently setting up a database that I would like to export a query with 1 column that has parameters set (single date) to an excel template from into a certain cell range.
I do not have a lot of experience in this field (VBA) but have pieced together something from here.
Now my issue that this code exports the query without parameters set but as soon as I set the date parameter the code doesn't work.
I was able to add the first code entry into the second but it only copied the date column across and didn't sort by the parameter.
Any help fixing this would be greatly appreciated.
A A Ron
Code:Dim qdf As DAO.QueryDef Dim prm As DAO.Parameter Set db = CurrentDbSet qdf = db.QueryDefs("table1 query") For Each prm In qdf.Parameters prm = Eval(prm.Name) Next prmThanksCode:Public Function Access2XL() Dim rst Dim XL As Excel.Application Set XL = CreateObject("excel.application") Dim vFile vFile = "\\Mac\Home\Documents\TEST DB\testss.xlsx" Set rst = CurrentDb.OpenRecordset("table1 query") With XL .Visible = True .Workbooks.Open vFile .Sheets("Sheet1").Select .Range("c4").Select .ActiveCell.CopyFromRecordset rst .ActiveWorkbook.Save End With Set rst = Nothing Set XL = Nothing End Function


Exporting from Access to Excel via Macro / VBA Help
Reply With Quote

