I have created a Allen Browne's type search form and result exported to excel format for more flexibility using following vba.
Dim qdf As DAO.QueryDef
Dim strWhere As String
Dim strFile As String
Const strcStub = "SELECT tblEquipment.*FROM tblEquipment" & vbCrLf
Const strcTail = "ORDER BY SomeField;"
Const strcExportQuery = "Query1"
If Me.FilterOn Then
strWhere = "WHERE" & Me.Filter & vbCrLf
End If
Set qdf = CurrentDb.CreateQueryDef("Query1", strcStub & strWhere)
strFile = "D:\DB\REPORT\MyExports.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, strcExportQuery, strFile
CurrentDb.QueryDefs.Delete "Query1"
Now I want to show the searched criteria(suppose [Equipment], [Date of Issued]) to show on the top of the excel worksheet as headings.
Is it possible ? Any help would be a great appreciate.
Dim qdf As DAO.QueryDef
Dim strWhere As String
Dim strFile As String
Const strcStub = "SELECT tblEquipment.*FROM tblEquipment" & vbCrLf
Const strcTail = "ORDER BY SomeField;"
Const strcExportQuery = "Query1"
If Me.FilterOn Then
strWhere = "WHERE" & Me.Filter & vbCrLf
End If
Set qdf = CurrentDb.CreateQueryDef("Query1", strcStub & strWhere)
strFile = "D:\DB\REPORT\MyExports.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, strcExportQuery, strFile
CurrentDb.QueryDefs.Delete "Query1"
Now I want to show the searched criteria(suppose [Equipment], [Date of Issued]) to show on the top of the excel worksheet as headings.
Is it possible ? Any help would be a great appreciate.
Attachments
Last edited: