I am a novice with access programming.And just started to learn.
I have a question similar to one of the posts in this forum.
I have a semester field that shoudl have input data in the format FSYYYY, SSYYYY OR SUYYYY (SS- spring, FS- Fall, SU-Summer and YYYY is the 4 digit year format.)
E.g. FS2010 for current semester.
The semesters in the university where i work run like this:
SS - 1/10/ TO 5/24/
SU - 6/6/ TO 8/9/
FS - 8/15/ TO 12/23/
i want to have a code that can check the current date with the above date ranges and and insert a yes if the semester is current and no if it is not.
That is if it is FS2010 then it is the current semester and Active field is "Yes"
I tried to use a code that is not mine(have found it in this forum), but i can't get it to work:
============================================
Expand|Select|Wrap|Line Numbers
- Private Sub Stu_title_subform_Current()
- ' 03/SP
- 'CDate : If you have a string or an expression that you want to convert to a date value, use CDate() based on the following formula:Result = CDate(Value to Convert)
- Select Case Left(Semester, 2)
- Case "SS"
- If Date >= CDate(Left(Semester, 2) & "1/10/") And Date <= CDate(Left(Semester, 2) & "5/24/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- Case "SU"
- If Date >= CDate(Left(Semester, 2) & "6/6/") And Date <= CDate(Left(Semester, 2) & "8/9/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- Case "Fs"
- If Date >= CDate(Left(Semester, 2) & "8/15/") And Date <= CDate(Left(Semester, 2) & "12/23/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- End Select
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Semester_AfterUpdate()
- Select Case Left(Semester, 2)
- Case "SS"
- If Date >= CDate(Left(Semester, 2) & "1/10/") And Date <= CDate(Left(Semester, 2) & "5/24/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- Case "SU"
- If Date >= CDate(Left(Semester, 2) & "6/6/") And Date <= CDate(Left(Semester, 2) & "8/9/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- Case "FS"
- If Date >= CDate(Left(Semester, 2) & "8/15/") And Date <= CDate(Left(Semester, 2) & "12/23/") Then
- Me.Active = "Yes"
- Else
- Me.Active = "No"
- End If
- End Select
- End Sub
Any help is much appreciated.
Thanks
m_i