[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Compare Y/N Field to Separate Table

I have searched but haven't been able to find a solution for this problem.

In an Access 2007 database I have inherited, there is a table, tblLenders, that includes various information on lenders and includes 12 Y/N fields, one for each federal holiday in the year.

There is also a table, tblHolidays, which lists a hoiday name and date for each federal holiday in the year.

I need to figure out how to exclude a record from a query of tblLenders if all of the criteria below are met...
1. Today's Date is present in tblHolidays
2.  The Holiday Name in tblLenders is "Y"

Ultimately, I am trying to obtain a list of lenders that are not closed on today's date.  Because of the way this data is stored, I can't figure this out.

For example...  if today's date (11/11/2010) is in the values in tblHolidays.Hdt, that would be VeteransDay (tblHolidays.Hnm); and tblLenders.VeteransDay = "Y" then this record should be excluded from the query.
0
rsburge
Asked:
rsburge
  • 7
  • 5
  • 2
3 Solutions
 
Rey Obrero (Capricorn1)Commented:
first create a Union query using tbllenders

select Id,lendername, [nameof first Y/N field] as Holiday from tblLenders
union All
select Id,lendername, [nameof second Y/N field] as Holiday from tblLenders
union all
select ....


union all
select Id,lendername, [nameof 12 Y/N field] as Holiday from tblLenders


after you have done this, post back here and we will continue

* use the appropriate names of fields in the union query






0
 
rsburgeAuthor Commented:
Ok, this is done...  this is the query I created qryUnionLndrHol

SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[NewYearsDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[MLKJrDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[WashingtonBday] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[MemorialDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[IndependenceDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[LaborDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[ColumbusDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[VeteransDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[ThanksGivingDay] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[DayAfterThnxgvng] AS holiday FROM tblLenders;
union all
SELECT tblLenders.ID, tblLenders.LenderName, tblLenders.[ChristmasDay] AS holiday FROM tblLenders;
0
 
Rey Obrero (Capricorn1)Commented:
that is only eleven,, any way

post sample data from tblHolidays including the name of the fields


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rsburgeAuthor Commented:
I apologize, it is only 11 holidays.

HolidayID - automated number and key field
HolidayNm - Name of Holiday (11 holiday names matching those in the query above)
HolidayDt - Short Date format

HolidayID     HolidayNm                HolidayDt
          1        NewYearsDay         1/1/2010
          2        MLKJrDay                 1/18/2010
and so on...
        11        ChristmasDay          12/24/2010

the HolidayDt field will be updated each year with the current year's dates.
0
 
Rey Obrero (Capricorn1)Commented:
ok, i'll be out for a while, can you upload a copy of your db..
0
 
rsburgeAuthor Commented:
unfortunately I can't upload a copy of the database; lots of confidential information in the tables.  No worries on your being out.  I am not in a huge hurry; I have two weeks before the next holiday.  :)  And I really appreciate your offering your assistance.
0
 
lluddenCommented:
SELECT tblLenders.ID, tblLenders.LenderName, tblHoliday.HolidayDt
FROM tblLenders, tblHoliday
WHERE (((tblLenders.NewYearsDay)=True) AND ((tblHoliday.HolidayNm)="New Years Day"))
UNION
SELECT tblLenders.ID, tblLenders.LenderName, tblHoliday.HolidayDt
FROM tblLenders, tblHoliday
WHERE (((tblLenders.Christmas)=True) AND ((tblHoliday.HolidayNm)="Christmas"))


This will give you a list of each customer and each holiday they are closed and the date of the holiday
(repeat the query for each holiday)

0
 
rsburgeAuthor Commented:
I am not sure how to use this solution...  My end goal is to have one complete list of the records from tblLenders that are open "today".

This list that I am trying to obtain will be the filter on a form.
0
 
lluddenCommented:
The query I gave you will return a list of all dates that each lender is closed.  If they are open any days they are not closed, then you can call the above query qryLenderClosedDates and do

SELECT LenderID, LenderName FROM tblLenders WHERE ID NOT IN (SELECT ID FROM qryLenderClosedDates WHERE HolidayDt = date())

This will show a list of all clients that are open on the current date, assuming they are only closed on the holidays.  You will need to exclude other days such as weekends.
0
 
rsburgeAuthor Commented:
Thank you for explaining that.  Let me give that a try.  I will post back as soon as possible.  Busy morning here, so it might be a few hours.
0
 
Rey Obrero (Capricorn1)Commented:
sorry, i lost track of this thread, don't know why..anyway

test this sample db,
run query2
DB-Q-26609108-Holidays.mdb
0
 
rsburgeAuthor Commented:
thank you capricorn1...  I will try this too.
0
 
Rey Obrero (Capricorn1)Commented:

this one show details in the form/subform



DB-Q-26609108-Holidays.mdb
0
 
rsburgeAuthor Commented:
I'm sorry I haven't had time to test these yet...  servers at the co-location have been up and down because of a DOS attack against the firewall.  I won't be able to test these until that is fixed.  I will get back to you as soon as I can.  Thanks again for your help!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now