I have a query set up which extracts the top 10 most frequently occurring ATAs from my main table and I will refer to this as the First Query.
I then use this query with the Second Query in order to pull out the rest of the fields associated with the top 10 most frequently occurring ATAs.
Just a little note regarding the Criteria that I have applied in the queries. The date criteria is given by filling in boxes on my reporting form and the ModelLink = 2 refers to filtering just the Boeing 737-300 aircraft that I have (I will be replicating this query and export another 2 times for the 737-800 and 757-200).
When I fill in the 2 date parameters (the only thing required to set the query) and look at the Second Query, the query filters the information perfectly. However, when I come to export the data using my code, a load of random columns which I have not included in my query are exported and some columns which I have asked to be renamed are not renamed.
Any ideas as to why this is happening? I managed to get it working one time for the 737-300 and 757-200 exports (I initially got the 737-300 set of queries working and then copied them over for the other 2), but then for some reason the 737-800 report started having the issue that I am replicating now. I tried deleting all the queries and trying to rebuild them, but I still keep getting this issue.
My end goal is to have my query exported into Excel and the workbook to open for the user to be able to edit the Excel spreadsheet as they choose. I also don't want the spreadsheet to be saved automatically with a filepath etc, I would rather the user chooses just via Excel whether they want to save it or not.
I then use this query with the Second Query in order to pull out the rest of the fields associated with the top 10 most frequently occurring ATAs.
Just a little note regarding the Criteria that I have applied in the queries. The date criteria is given by filling in boxes on my reporting form and the ModelLink = 2 refers to filtering just the Boeing 737-300 aircraft that I have (I will be replicating this query and export another 2 times for the 737-800 and 757-200).
When I fill in the 2 date parameters (the only thing required to set the query) and look at the Second Query, the query filters the information perfectly. However, when I come to export the data using my code, a load of random columns which I have not included in my query are exported and some columns which I have asked to be renamed are not renamed.
Any ideas as to why this is happening? I managed to get it working one time for the 737-300 and 757-200 exports (I initially got the 737-300 set of queries working and then copied them over for the other 2), but then for some reason the 737-800 report started having the issue that I am replicating now. I tried deleting all the queries and trying to rebuild them, but I still keep getting this issue.
My end goal is to have my query exported into Excel and the workbook to open for the user to be able to edit the Excel spreadsheet as they choose. I also don't want the spreadsheet to be saved automatically with a filepath etc, I would rather the user chooses just via Excel whether they want to save it or not.
Code:
Private Sub Top10ATA738Expt_Click()
Dim dbsCurrent As Database
Dim SQL_Name As QueryDef
Dim SQL_Output As String
Dim dStart As String
Dim dEnd As String
Set dbsCurrent = CurrentDb
Set SQL_Name = dbsCurrent.QueryDefs("Top10ATA737800")
DoCmd.Echo False
DoCmd.OpenQuery "Top10ATA737800"
Call FormatExcelTop10ATAExport("Top10ATA737800.xlsx")
DoCmd.Close acQuery, "Top10ATA737800"
DoCmd.Echo True
End Sub