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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatePart referring to field on a form

Status
Not open for further replies.

weezles

Technical User
Jul 18, 2003
81
GB
Hi

I want to return records where the year of a date in each record matches a year the user enters on a form. I have the following where clause:

WHERE (DatePart("yyyy",[tblClient.DateA])=[forms]![frmRptMenu].[form]![txtYear])

I get no records returned although this works if i just enter the year within the query.

Any suggestions?

Thanks

Lou
 
Hi,

try converting the text date on the form to integer via CInt function
Code:
WHERE (DatePart("yyyy",[tblClient.DateA])=CInt([forms]![frmRptMenu].[form]![txtYear]))

Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
And this ?
WHERE Year([tblClient.DateA])=[Forms]![frmRptMenu]![txtYear]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

I tried both of your suggestions, unfortunately neither worked. However both work if i replace
[Forms]![frmRptMenu]![txtYear] with an actual year.
I have checked the form and field names are spelt correctly so I dont know what else to try.

thanks

Lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top