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

datepart d function oops 1

Status
Not open for further replies.

rudolfelizabeth

Programmer
Jan 14, 2009
89
0
0
CW
Hi,

The code below should produce all the days of the year in the database the user ask for in a query

aliasmyday: (DatePart("d",[Saledate])

criteria Like ("*" & [Search_My_daynumber])

for example if the user input 01 it should brings all the data of all the years on the first day of each month present in
the databases
 
DatePart returns number, why do you compare it with string instead directly have [Search_My_daynumber] in criteria? You may have problem with single digit days, for instance if DatePart returns 1, you get in criteria Like *01, resulting no match.

combo
 
try your code doesn't work

query must provide the following results
if user input 1
it should give the sales on the 1 of January first of 1 February and so on.
 
Why do you think you need a like? Does not make sense. So assume the user enters "2" do you want to return 2, 20, 21..29.

Should simply be
Day([SaleDate]: returns 1 to 31
[search_My_DayNumber]: input should be 1,2 to 31 and not 01..09
If you input a 01 it will be interpretted as a string and should not compare as combo has stated.
 
If the user enter 2 it should bring up 2 of January the 2 of February and the 2 of march and so on
 
I would add a combo box with 1-31 as a row source on a form and then set the criteria to:

Code:
=Forms![YourFormName]![YourComboBoxName]

It is easiest to use the Day([SaleDate]) as pointed out by MajP.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
If the user enter 2 it should bring up 2 of January the 2 of February and the 2 of march and so on
Yes, everyone has figured that out and has told you how to do it correctly. Why do you keep saying that? Using "like" does not get you there. Do you understand what the "like" syntax does?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top