jeran042
Registered User.
- Local time
- Today, 03:35
- Joined
- Jun 26, 2017
- Messages
- 127
Here is the problem,
I have a form "frm: Report Creator" with a subform that is linked to a query. Basically the parent form acts like is a report creator. Where a user can input data into any field to pull results to the subform. On the parent form, I also have a field (txtFilter) that pulls the filter property from the subform, and that is where I am storing my WHERE clause. And all this works as expected.
My problem is, I want the ability to export the results from from the subform to excel. Here is the code that I am using:
I have verified that I have full permission to write to the folder on my desktop, and the table has an Auto number field with the index set to "Yes (No Duplicates)" (I have read that this can cause the run time error)
I am stuck on how to proceed, and would appreciate any direction
Also, if there is a better way to achieve this, I will be willing to try it,
Very much appreciated,
I have a form "frm: Report Creator" with a subform that is linked to a query. Basically the parent form acts like is a report creator. Where a user can input data into any field to pull results to the subform. On the parent form, I also have a field (txtFilter) that pulls the filter property from the subform, and that is where I am storing my WHERE clause. And all this works as expected.
My problem is, I want the ability to export the results from from the subform to excel. Here is the code that I am using:
Code:
Private Sub cmdOutputXLSX_Click()
Dim strSQL As String
Dim strQry As String
Dim myPath As String
Dim sFileName As String
Set DB = CurrentDb
Set Qdf = DB.CreateQueryDef(strQry, strSQL)
myPath = "C:\Users\jrenald\Desktop\Budget process information"
sFileName = " Custom Report " & Format(Date, "_mmddyy") & ".pdf"
strSQL = "SELECT * FROM COPY_TBL_LEDGER_DETAIL WHERE me.txtFilter"
strQry = "TempSELECTName"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, _
strQry, myPath + sFileName, True
'DoCmd.DeleteObject acQuery, strQry
End Sub
I have verified that I have full permission to write to the folder on my desktop, and the table has an Auto number field with the index set to "Yes (No Duplicates)" (I have read that this can cause the run time error)
I am stuck on how to proceed, and would appreciate any direction
Also, if there is a better way to achieve this, I will be willing to try it,
Very much appreciated,