Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching by year when field holds entire date

Status
Not open for further replies.
Jan 27, 2003
35
0
0
GB
OK here goes:

I have a table containing personal details, one of the fields is date of birth.

I have a form (form 2)which i use to open another form (form 1)which contains personal data (form 2) is opened from form 1 in order to perform a search (not too important)

Form 2 contains only a text box and a button (created with the wizard) and it works great i can search through the records by typing the full date of birth in the text box i.e 08/08/1978 and clicking the button.

I want to be able to search through the records so that i find all the people born in a specific year, by typing 1978 in the text box how do i do this?
 
What you're looking for is the Year() function. It will return the year for any date input. This means that you can put something like this when creating a filter:

"Year([myFieldName]) = " & txtMyInput.Value

instead of what you currently have, which probably looks like:

"[myFieldName = #" & txtMyInput.Value & "#" --
Find common answers using Google Groups:

 
You could also use the DatePart("yyyy", DateFieldName) function. PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top