Hi guys,
At the moment I've got a form with a subform. On the form are 5 comboboxes that filter the subform. I want to be able to export the filtered recordset to Excel and through my reading it seems that a query is the best way to do it. I'm having problems getting the variables from the combos into the query though. I tried to do it simply but after a lot of frustration I made a new query and just put in an example filter set to see where to insert the variables to get the output I need. Here's what the Query came out as with my imaginary filter set:
It looks very complex for what I want to do, but running that query gives the exact results I want in the exported excel. I just need the filter values to be dynamic based on:
I don't know if the above is correct being that I've got forms and subforms going on.
Can anyone edit the above to show me how to get the results I need?
Thanks!
At the moment I've got a form with a subform. On the form are 5 comboboxes that filter the subform. I want to be able to export the filtered recordset to Excel and through my reading it seems that a query is the best way to do it. I'm having problems getting the variables from the combos into the query though. I tried to do it simply but after a lot of frustration I made a new query and just put in an example filter set to see where to insert the variables to get the output I need. Here's what the Query came out as with my imaginary filter set:
Code:
SELECT tblPartnersets.[Partner name], tblRecords.WeekID, tblCountries.Region, tblCountries.Country, tblChannels.Channel
FROM tblWeeks INNER JOIN ((tblCountries INNER JOIN (tblChannels INNER JOIN tblPartnersets ON tblChannels.ChannelID = tblPartnersets.ChannelID) ON tblCountries.CountryID = tblPartnersets.CountryID) INNER JOIN tblRecords ON tblPartnersets.PartnersetID = tblRecords.PartnersetID) ON tblWeeks.WeekID = tblRecords.WeekID
WHERE (((tblPartnersets.[Partner name])="PartnerABC") AND ((tblRecords.WeekID)=28) AND ((tblCountries.Region)="RegionABC") AND ((tblCountries.Country)="CountryABC") AND ((tblChannels.Channel)="ChannelABC"));
It looks very complex for what I want to do, but running that query gives the exact results I want in the exported excel. I just need the filter values to be dynamic based on:
Code:
vRegion = cboRegion.value
vWeek = cboWeek.value
vPartner = cboPartner.value
vCountry = cboCountry.value
vChannel = cboChannel.value
I don't know if the above is correct being that I've got forms and subforms going on.
Can anyone edit the above to show me how to get the results I need?
Thanks!