How query table for birthdays in a selected month

I have a form that has a field that the user can select a month name from.  (January, February, etc.)  Then I want to query  the table that has employee names and birthdays.  But the birthdays are stored as for example, 2/15/1985 or 12/30/2010.

How can I query those employees for the birthdays in the month selected?
SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
Select ....
From ...
Where Month(DOB) = Forms!yourform!cboMonth
Order By Day(DOB);
SteveL13Author Commented:
Hmmm, isn't working.

Here is my SQL:

SELECT [LAST NAME] & ", " & [FIRST NAME] AS [Player Name], [mail list].DateOfBirth INTO TEMPBirthdayList
FROM [mail list]
WHERE (((Month([DateOfBirth]))=[Forms]![frmBirthdayList]![cboMonth]))
ORDER BY [LAST NAME] & ", " & [FIRST NAME];

Open in new window


But for example, if I select "August" from the combobox, I get no records.

Does it matter that the combobox is a value list?  Using:

"January";"February";"March";"April";"May";"June";"July";"August";"September";"October";"November";"December"

--Steve
Gustav BrockCIOCommented:
This function does exactly that:
Public Function IsBirthday( _
  ByVal datDateOfBirth As Date, _
  Optional varDate As Variant) _
  As Boolean

' Returns True if date varDate (or today) is an annual birthday.
' Validates correctly Feb. 29. as Feb. 28. for non leap years and
' excludes annual birthdays earlier than the date of birth.
'
' Gustav Brock, Cactus Data ApS.
' 2000-12-20.
' 2008-05-12. Converted to stand-alone function.

  Dim datDate     As Date
  Dim booBirthday As Boolean
  
  ' No special error handling.
  On Error Resume Next
  
  If IsDate(varDate) Then
    datDate = Fix(CDate(varDate))
  Else
    datDate = Date
  End If
  booBirthday = (DateDiff("d", datDate, DateAdd("yyyy", Abs(DateDiff("yyyy", datDateOfBirth, datDate)), datDateOfBirth)) = 0)

  IsBirthday = booBirthday

End Function

Open in new window

/gustav
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

SteveL13Author Commented:
But then how do I use the function in a maketable query?
Gustav BrockCIOCommented:
Month returns the month number, so your value list should have two columns:

1;"January";2;"February";3;"March";4;"April";5;"May";6;"June";7;"July";8;"August";9;"September";10;"October";11;"November";12;"December"

Bind the first column, and set ColumnWidths to: 0;

/gustav

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gustav BrockCIOCommented:
Modify the SQL:
SELECT 
    [LAST NAME] & ", " & [FIRST NAME] AS [Player Name], [mail list].DateOfBirth 
INTO 
    TEMPBirthdayList
FROM 
    [mail list]
WHERE
    Month([DateOfBirth])=[Forms]![frmBirthdayList]![cboMonth]
    AND
    IsBirthday([DateOfBirth]) = True
ORDER BY 
    [LAST NAME] & ", " & [FIRST NAME];

Open in new window

/gustav
SteveL13Author Commented:
This suggestion worked perfectly.  Thank you.
Amit KumarCommented:
Please build query function as mentioned

Expr1: MonthName(Month([Table1]![DB]),False)

Note: Expr1 is dummy expression which will be created in query and Table1 is table name and DB is birthday date.

Then you can create form accordingly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.