Samantha
still learning...
- Local time
- Today, 08:57
- Joined
- Jul 12, 2012
- Messages
- 182
Hi all, I am learning and have been for a few years so I am familiar with a little bit of everything. I am using Access 2010. I am not quite sure how to complete what I want - I am half way there.
With the holidays approaching I am trying to generate a Holiday Mailing Report to make my life easier this year. So my database has all my customers info and jobs (proposals) quoted. I started by creating a qry from tblProposals including the company name, contact, and date of anything after Jan 2012. So this returns all of people we have worked with over the time period specified.
Next, I created a table "tblHoliday" it includes HolidayID (PK) and ContactID (FK), Comments, then also 6 more fields (yes/no) Gift & Card for the past 3 years -2011, 2012, & 2013. I created a qry based on this table to tie back in the contact name and addresses and eliminate any inactive clients as well.
From here I have made a third "qryCustomersGettingCards" to tie the two previous together
This all works just fine - my problem is I don't want to eliminate anyone that received a card in a previous year and didn't have work done in the time frame specified. My thoughts and from searching are that I need some type of ingenious vba statement where it would cycle through each of the 6 fields and if one is true it would return that record. I am lost on how to accomplish this I would guess in my second query?
Any help is greatly appreciated!
So taking that approach a step further I changed the second qry to the following
Which does return the information I want - but now to smush them together into that third qry there is no option for all records - just equal, right, or left join
With the holidays approaching I am trying to generate a Holiday Mailing Report to make my life easier this year. So my database has all my customers info and jobs (proposals) quoted. I started by creating a qry from tblProposals including the company name, contact, and date of anything after Jan 2012. So this returns all of people we have worked with over the time period specified.
Code:
SELECT DISTINCT tblProposals.Company, tblProposals.Contact, tblProposals.DateGenerated, Contacts.ContactName
FROM (((tblLookupCityState INNER JOIN tblLookupServiceAddress ON tblLookupCityState.City = tblLookupServiceAddress.City) INNER JOIN tblProposals ON tblLookupServiceAddress.ServiceAddress = tblProposals.ServiceAddress.Value) LEFT JOIN tblWOH ON tblProposals.JobNumber = tblWOH.JobNumber) INNER JOIN Contacts ON (tblLookupCityState.City = Contacts.City) AND (tblProposals.Contact = Contacts.ContactID)
WHERE (((tblProposals.DateGenerated)>#1/1/2012#));
Next, I created a table "tblHoliday" it includes HolidayID (PK) and ContactID (FK), Comments, then also 6 more fields (yes/no) Gift & Card for the past 3 years -2011, 2012, & 2013. I created a qry based on this table to tie back in the contact name and addresses and eliminate any inactive clients as well.
Code:
SELECT DISTINCT Contacts.ContactName, tblHoliday.ContactID, tblHoliday.HolidayID, tblHoliday.Comments, tblHoliday.[2013 Gift], tblHoliday.[2013 Card], tblHoliday.[2012 Gift], tblHoliday.[2012 Card], tblHoliday.[2011 Card], tblHoliday.[2011 Gift], Contacts.Company, Contacts.Address, Contacts.State, Contacts.ZipCode, Contacts.City
FROM tblHoliday INNER JOIN Contacts ON tblHoliday.ContactID = Contacts.ContactID
WHERE (((Contacts.Inactive) Is Not Null));
From here I have made a third "qryCustomersGettingCards" to tie the two previous together
Code:
SELECT DISTINCT qryHolidayCards.ContactName, qryHolidayCards.Comments, qryHolidayCards.[2013 Gift], qryHolidayCards.[2013 Card], qryHolidayCards.[2012 Gift], qryHolidayCards.[2012 Card], qryHolidayCards.[2011 Card], qryHolidayCards.[2011 Gift], qryHolidayCards.Company, qryHolidayCards.Address, qryHolidayCards.State, qryHolidayCards.ZipCode, qryHolidayCards.City
FROM qryFrequentCustomers LEFT JOIN qryHolidayCards ON qryFrequentCustomers.Contacts.ContactName = qryHolidayCards.ContactName;
Any help is greatly appreciated!
So taking that approach a step further I changed the second qry to the following
Code:
SELECT DISTINCT Contacts.ContactName, tblHoliday.ContactID, tblHoliday.HolidayID, tblHoliday.Comments, tblHoliday.[2013 Gift], tblHoliday.[2013 Card], tblHoliday.[2012 Gift], tblHoliday.[2012 Card], tblHoliday.[2011 Card], tblHoliday.[2011 Gift], Contacts.Company, Contacts.Address, Contacts.State, Contacts.ZipCode, Contacts.City
FROM tblHoliday INNER JOIN Contacts ON tblHoliday.ContactID = Contacts.ContactID
WHERE (((tblHoliday.[2012 Gift])=True)) OR (((tblHoliday.[2012 Card])=True)) OR (((tblHoliday.[2011 Card])=True)) OR (((tblHoliday.[2011 Gift])=True) AND ((Contacts.Inactive) Is Not Null));
Last edited: