?
Solved

Compare Y/N Field to Separate Table

Posted on 2010-11-11
14
Medium Priority
?
392 Views
Last Modified: 2012-05-10
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
Comment
Question by:rsburge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34115314
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
 

Author Comment

by:rsburge
ID: 34115487
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34115700
that is only eleven,, any way

post sample data from tblHolidays including the name of the fields


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:rsburge
ID: 34115843
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34115854
ok, i'll be out for a while, can you upload a copy of your db..
0
 

Author Comment

by:rsburge
ID: 34116158
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
 
LVL 18

Expert Comment

by:lludden
ID: 34116516
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
 

Author Comment

by:rsburge
ID: 34139085
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
 
LVL 18

Assisted Solution

by:lludden
lludden earned 668 total points
ID: 34155079
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
 

Author Comment

by:rsburge
ID: 34155451
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
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1332 total points
ID: 34155615
sorry, i lost track of this thread, don't know why..anyway

test this sample db,
run query2
DB-Q-26609108-Holidays.mdb
0
 

Author Comment

by:rsburge
ID: 34155791
thank you capricorn1...  I will try this too.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1332 total points
ID: 34158307

this one show details in the form/subform



DB-Q-26609108-Holidays.mdb
0
 

Author Comment

by:rsburge
ID: 34164561
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question