Hi
With loads of help from vbaInet I was able to create a form with lots of conditional formatting that did pretty much everything I wanted it to do. The only problem is that it takes about 4 full minutes for the form to open.
As an experiment I am reluctantly now trying to display the results in Excel. I have created a template xls sheet and all I want to do is, on the press of a button, copy the results from my query and paste them in to cell a1 of my spreadsheet.
I found the following code online which I am trying to adapt.
My limited knowledge however results in a couple of errors.
The first error User defined type not defined error appears at the very first line of my code
The next error occurs as I am not sure how to reference the query to export. The query is called 2014 Resources and outputs also to a form called 2014 Resources.
Can anyone help?
With loads of help from vbaInet I was able to create a form with lots of conditional formatting that did pretty much everything I wanted it to do. The only problem is that it takes about 4 full minutes for the form to open.
As an experiment I am reluctantly now trying to display the results in Excel. I have created a template xls sheet and all I want to do is, on the press of a button, copy the results from my query and paste them in to cell a1 of my spreadsheet.
I found the following code online which I am trying to adapt.
Code:
Private Sub update_tracker_Click()
Dim XL As Excel.Application
Dim wbTarget As Workbook
Dim qdfResults As QueryDef
Dim rsResults As Recordset
'Set up refernce to the query to export
Set qdfResults = CurrentDb.QueryDefs("2014 Resources")
qdfResults.Parameters("Forms!2014 Resources") = Forms!2014 Resources
'Execute Query
Set rsResults = qdfResults.OpenRecordset()
'reference excel
Set XL = CreateObject("Excel.Application")
'refernce workbook
Set wbTarget = XL.Workbooks.Open("I:\Documents\Access files\skeleton db\2014 Resources.xlsx")
'clear excel sheet
wbTarget.Worksheets("_2014_Resources").Cells.ClearContents
'paste data from query to worksheet
wbTarget.Worksheets("_2014_Resources").Cells(1, 1).CopyFromRecordSet rsResults
wbTarget.SaveAs "I:\Documents\Access files\skeleton db\2014 Resources.xlsx", xlOpenXMLWorkbookMacroEnabled
wbTarget.Close
Set wbTarget = Nothing
XL.Quit
End Sub
The first error User defined type not defined error appears at the very first line of my code
Code:
Dim XL As Excel.Application
Can anyone help?