Jayz
ISP
- Feb 17, 2002
- 59
Ok, I'm almost there. I created a continuous form based on a query and then created some code that would export the results to Excel on a click of a button.
The problem is, when I filter the data on the form using the right click option "filter by selection", and then export it to Excel, the resultant data in excel is not filtered.
Can someone please provide a code that will export the filtered data from my form to Excel.
Thanks,
Jay
Here is the current code I'm using:
'********************************************
Private Sub Export_Click()
Dim xlApp As Object
'Check if Workbook is Open
If IsWorkbookOpen("OM_Search1.xls"
= False Then
DoCmd.TransferSpreadsheet acExport, 8, "OM_Search_query1", "C:\Genie_Export\OM_Search1.xls", True
Set xlApp = CreateObject("excel.application"
xlApp.Visible = True
xlApp.Workbooks.open "c:\GENIE_Export\OM_Search1.xls" 'Path to your file
Else
'If IsWorkbookOpen("*.xls"
= True And IsWorkbookOpen("OM_Search1.xls"
= True Then
MsgBox "OM_Search1.xls is currently open. Please close the spreadsheet before exporting data. Note: current data will be overwritten", vbExclamation
End If
End Sub
'*******************************************************
The problem is, when I filter the data on the form using the right click option "filter by selection", and then export it to Excel, the resultant data in excel is not filtered.
Can someone please provide a code that will export the filtered data from my form to Excel.
Thanks,
Jay
Here is the current code I'm using:
'********************************************
Private Sub Export_Click()
Dim xlApp As Object
'Check if Workbook is Open
If IsWorkbookOpen("OM_Search1.xls"
DoCmd.TransferSpreadsheet acExport, 8, "OM_Search_query1", "C:\Genie_Export\OM_Search1.xls", True
Set xlApp = CreateObject("excel.application"
xlApp.Visible = True
xlApp.Workbooks.open "c:\GENIE_Export\OM_Search1.xls" 'Path to your file
Else
'If IsWorkbookOpen("*.xls"
MsgBox "OM_Search1.xls is currently open. Please close the spreadsheet before exporting data. Note: current data will be overwritten", vbExclamation
End If
End Sub
'*******************************************************