I'm doofus when it comes to SQL, Marshall.
Part of my problem is that I don't know the YEAR for quite a few of my
contacts' birthdays and/or anniversaries... so I have a field with
month/day/1800 on which I'm building this query & report. (Just explaining
why the field names are "bogus_____date". Here's my SQL statement:
SELECT tblContacts.LastName, tblContacts.FirstName,
tblContacts.BirthdayCardList, tblContacts.BogusBirthday,
tblContacts.AnniversaryCardList, tblContacts.BogusAnniversary
FROM tblContacts
WHERE (((tblContacts.BirthdayCardList)=Yes)) OR
(((tblContacts.AnniversaryCardList)=Yes))
ORDER BY tblContacts.LastName, tblContacts.FirstName;
If I'm understanding you correctly, I should try something like this:
SELECT tblContacts.LastName, tblContacts.FirstName,
tblContacts.BirthdayCardList, "BogusBirthday" As CardType, bogusbirthday As
XDate
FROM tblContacts
WHERE BogusBirthday Between [Start Date] And [End Date]
UNION ALL
SELECT tblContacts.LastName, tblContacts.FirstName, "BogusAnniversary" As
CardType, bogusanniversary
FROM tblContacts
WHERE bogusanniversary Between [Start Date] And [End Date]
I tried that & got the following message: "The number of columns in the two
selected tables or queries of a union query do not match."
"Marshall Barton" wrote
Sue said:
I have 2 fields - birthday & anniversary. Each are date/time fields with
mm/dd/yy formatting.
I've got 2 separate queries & reports - one for anniversaries & one for
birthdays - that I've designed to serve as a crutch for my feeble mind - a
reminder that birthdays or anniversaries are coming up & that there are
cards to send, presents to buy...
Is there any way to combine the 2 of these so that both birthdays and
anniversaries are both sorted all at once & thus I'll have a report that
shows me BOTH birthdays & anniversaries sorted by month & day?
Not exactly sure what you want here, but I think you can get
a nice effect this way.
First create a query that uses a combined field for the
dates:
SELECT person, "Birthday" As CardType, birthday As XDate
FROM yourtable
WHERE Birthdate Between [Start Date] And [End Date]
UNION ALL
SELECT person, "Anniversary" As CardType, anniversary
FROM yourtable
WHERE Birthdate Between [Start Date] And [End Date]
Then change one of your reports to use the CardType and
XDate (instead of birthday).