chrisjames25
Registered User.
- Local time
- Today, 21:56
- Joined
- Dec 1, 2014
- Messages
- 401
Hi
I have a mainform and in the header of that form their is a command button to create a report.
WHat i have in the form is the header of the main form, then a subform within the detail of the form. THe subform is a continuous form made to look like a posh datasheet which is able to be filtered and sorted via drop downs or a search box.
I have the following code which is doing half the job.
This takes into account anything that has been filtered by using the txt search box but it does not take into account anything that has been filtered using the drop down filters. I had the same problem with exporting data and you guys solved problem for me using the following:
HOwever i am unsure whether this is the correct approach in this case and if so how to tweak the code to make it work.
Any help massively appreciated.
I have a mainform and in the header of that form their is a command button to create a report.
WHat i have in the form is the header of the main form, then a subform within the detail of the form. THe subform is a continuous form made to look like a posh datasheet which is able to be filtered and sorted via drop downs or a search box.
I have the following code which is doing half the job.
Code:
DoCmd.OpenReport "report1", acViewReport, "Qry_Main_VarietyForm"
This takes into account anything that has been filtered by using the txt search box but it does not take into account anything that has been filtered using the drop down filters. I had the same problem with exporting data and you guys solved problem for me using the following:
Code:
Dim strSql As String
Dim TempQdf As QueryDef
Dim db As DAO.Database
Set db = CurrentDb
strSql = "Select * from Qry_Main_VarietyForm"
If Me.Frm_Subform.Form.Filter <> "" Then
strSql = strSql & " WHERE " & Me.Frm_Subform.Form.Filter
End If
Set TempQdf = db.CreateQueryDef("ExportFiltereds", strSql)
DoCmd.OutputTo acOutputQuery, TempQdf.Name, acFormatXLSX
db.QueryDefs.Delete TempQdf.Name
HOwever i am unsure whether this is the correct approach in this case and if so how to tweak the code to make it work.
Any help massively appreciated.