XelaIrodavlas
Registered User.
- Local time
- Today, 20:02
- Joined
- Oct 26, 2012
- Messages
- 175
I had to double check too... for some reason my form wont pick up the 31st of any month in my input form (jan, mar, may, july, aug, oct, dec).
I have a simple search form (no control source) that runs a query which is based on the records between two input dates (text boxes). These could be any days, but could also be by month, so for the users convenience I wanted an option to just choose a month and year, which would automatically fill out the input boxes.
Maybe there's an easy way to do this? This is how I tried...
The start date box was easy, i just set the control source to:
="01/" & [Month] & "/" & [Year]
which produces normal dates like 01/02/2013 or 01/11/2010.
But because the months have different number of days, the ending date was a bit more complex, I used iif statements in the control source and have this:
=IIf([Month]="02" And [Year]/4=Int([Year]/4),"29/" & [Month] & "/" & [Year],
IIf([Month]="02","28/" & [Month] & "/" & [Year],
IIf([Month]="04" Or "06" Or "09" Or "11","30/" & [Month] & "/" & [Year],
IIf([Month]="01" Or "03" Or "05" Or "07" Or "08" Or "10" Or "12","31/" & [Month] & "/" & [Year],"FALSE"))))
The "01" bits refer to the bound column reference in each month, february is 02, december is 12 etc.
This successfully sets the date to the 28th if February (29th on leap years, see first line), and the 30th for Apr, June, Sep and Nov. But for some reason the last IIf statement doesn't work right, it just keeps setting it to the 30th, and i can't change it manually.. so if i run the query it then works only until the 30th of these months even when there's 31 days.
Have I made a really simple mistake and just can't see it? it should be working... but it isn't...
Any ideas? Thanks
I have a simple search form (no control source) that runs a query which is based on the records between two input dates (text boxes). These could be any days, but could also be by month, so for the users convenience I wanted an option to just choose a month and year, which would automatically fill out the input boxes.
Maybe there's an easy way to do this? This is how I tried...
The start date box was easy, i just set the control source to:
="01/" & [Month] & "/" & [Year]
which produces normal dates like 01/02/2013 or 01/11/2010.
But because the months have different number of days, the ending date was a bit more complex, I used iif statements in the control source and have this:
=IIf([Month]="02" And [Year]/4=Int([Year]/4),"29/" & [Month] & "/" & [Year],
IIf([Month]="02","28/" & [Month] & "/" & [Year],
IIf([Month]="04" Or "06" Or "09" Or "11","30/" & [Month] & "/" & [Year],
IIf([Month]="01" Or "03" Or "05" Or "07" Or "08" Or "10" Or "12","31/" & [Month] & "/" & [Year],"FALSE"))))
The "01" bits refer to the bound column reference in each month, february is 02, december is 12 etc.
This successfully sets the date to the 28th if February (29th on leap years, see first line), and the 30th for Apr, June, Sep and Nov. But for some reason the last IIf statement doesn't work right, it just keeps setting it to the 30th, and i can't change it manually.. so if i run the query it then works only until the 30th of these months even when there's 31 days.
Have I made a really simple mistake and just can't see it? it should be working... but it isn't...
Any ideas? Thanks