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

Need to default to current school year 2

Status
Not open for further replies.

tadimil

Programmer
Aug 26, 2003
19
US
I have a form currently with a combo box [test year]listing years:
2003-2004
2004-2005
2005-2006
2006-2007
and so...
I need it to default to the current school year.
Range of date is June 30, 2004 to June 30, 2005 are the for the 2004-2005. The month and day will always be June 30th...it's the year that will be changing.
Whenever the form is opened, it should look at the current date and then decide which school year it is in and the field should default to that.
I'd appreciate any help with this.
Thanks!
 
Hi,

Sou you take the Now date and subtract 5 Months and it will calculate the the School year
[tt]
SchoolYear = Year(DateSerial(Year(Now), Month(Now)-5, Day(now)))
[/tt]
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Wow! quick response thanks!

I tried that and I get "2004" as a result.
Our current date is July 29, 2004...which should fall in the school year of 2004-2005.
I need the forms!formname.[text year] to default to
"2004-2005".
It's a combo box that the user can change years. But, I want it to default to the current school year.
The combo box has a table called "Test Years" as it's record source. In the table has one column only, it's data is as follows:

2003-2004
2004-2005
2005-2006
2006-2007

and so on...

This is all one field in the table.

Do you have a solution for this? Thanks again!
 
tadimil-

Try this code:

Code:
Dim dt As Date
Dim theRange

dt = "06/30/" & Year(Now())
If Range("E15").Value < dt Then
    theRange = CStr(Year(Now()) - 1) & "-" & CStr(Year(Now()))
Else
    theRange = CStr(Year(Now())) & "-" & CStr(Year(Now()) + 1)
End If
ComboBox1.Value = theRange

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Code:
SchoolYear = Year(DateSerial(Year(Now), Month(Now)-5, Day(now)))& "-" & Year(DateSerial(Year(Now)+1, Month(Now)-5, Day(now)))


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
revused
Code:
SchoolYr = Year(DateSerial(Year(dNow), Month(dNow) - 5, Day(dNow) + 2)) & "-" & _
         Year(DateSerial(Year(dNow) + 1, Month(dNow) - 5, Day(dNow) + 2))
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Skip and cLFlaVA ~
Thank you...thank you...very much! I ended up using cLFlaVA's code. It worked exactly as I needed.

As soon as I can figure out how to do the stars...Stars for you both!

Thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top