Milothicus
Registered User.
- Local time
- Today, 09:49
- Joined
- Sep 24, 2004
- Messages
- 134
I have this ugly criterion for a date range:
Between DateSerial([Forms]![frmQtHst]![txtYear1],[Forms]![frmQtHst]![cboMonth1],1) And DateSerial([Forms]![frmQtHst]![txtYear2],[Forms]![frmQtHst]![cboMonth2]+1,1-1)
frmQtHst is the Quote History form, which allows the user to select a range with a starting month (cboMonth1) and year (txtYear1) and the same for ending year.
the logic is a little strange in the second dateserial. it's format is:
dateserial(year, month + 1, 1-1)
meaning it takes the year as it is, adds one to the month, and chooses the day before the first, so if you enter feb, it looks at mar, and looks at the day before the 1st of mar, selecting the last day in feb, regardless of how many days there are in feb.
this works fine, as long as dec. 31 / jan. 1 isnt within the range. i believe the problem occurs when you choose dec as the ending month, because adding one to the month and subtracting a day changes years.
i'm pretty sure i got the basis for this code from the MS website. jerks.
Between DateSerial([Forms]![frmQtHst]![txtYear1],[Forms]![frmQtHst]![cboMonth1],1) And DateSerial([Forms]![frmQtHst]![txtYear2],[Forms]![frmQtHst]![cboMonth2]+1,1-1)
frmQtHst is the Quote History form, which allows the user to select a range with a starting month (cboMonth1) and year (txtYear1) and the same for ending year.
the logic is a little strange in the second dateserial. it's format is:
dateserial(year, month + 1, 1-1)
meaning it takes the year as it is, adds one to the month, and chooses the day before the first, so if you enter feb, it looks at mar, and looks at the day before the 1st of mar, selecting the last day in feb, regardless of how many days there are in feb.
this works fine, as long as dec. 31 / jan. 1 isnt within the range. i believe the problem occurs when you choose dec as the ending month, because adding one to the month and subtracting a day changes years.
i'm pretty sure i got the basis for this code from the MS website. jerks.
Last edited: