Carmen
Registered User.
- Local time
- Today, 05:08
- Joined
- Nov 30, 2001
- Messages
- 58
One of these days I'll figure out how to code on my own! I really appreciate all the help I get from this forum. Here's my latest problem: I have a field that is generated from 2 other fields-a combination of date and module id. I need to be able to compare the date and module id of a new entry with ones already entered, and if there is a match then increment by one. Here is my code, maybe that will help make this more clear:
Function calcsecid()
'capture the year of session 1 date as yr and label the fall and _
spring semesters according to the month of session 1. Combine _
yr, sem, and module id to create the section ID field.
ModID = Forms!frmClasses!ModuleID
session = Forms!frmClasses!Session1
yr = Year(session)
If (DatePart("m", [session]) <= 6) Then
sem = "SP"
ElseIf (DatePart("m", [session]) >= 7) Then
sem = "FA"
End If
strSecID = yr & sem & "M" & ModID & "-" & 0
If Not IsNull(SectionID) Then
RecCnt = DCount("me.SectionID", "Forms!frmClasses", _
strSecID = Left(Me.SectionID, InStr(Me.SectionID, "0")))
If RecCnt > 0 Then
rnum2 = RecCnt + 1
Else
rnum2 = 1
End If
End If
calcsecid = strSecID & rnum2
Me.SectionID = calcsecid
End Function
I works great until I get to the RecCnt line. Can anyone please give me a clue? Thanks!
Function calcsecid()
'capture the year of session 1 date as yr and label the fall and _
spring semesters according to the month of session 1. Combine _
yr, sem, and module id to create the section ID field.
ModID = Forms!frmClasses!ModuleID
session = Forms!frmClasses!Session1
yr = Year(session)
If (DatePart("m", [session]) <= 6) Then
sem = "SP"
ElseIf (DatePart("m", [session]) >= 7) Then
sem = "FA"
End If
strSecID = yr & sem & "M" & ModID & "-" & 0
If Not IsNull(SectionID) Then
RecCnt = DCount("me.SectionID", "Forms!frmClasses", _
strSecID = Left(Me.SectionID, InStr(Me.SectionID, "0")))
If RecCnt > 0 Then
rnum2 = RecCnt + 1
Else
rnum2 = 1
End If
End If
calcsecid = strSecID & rnum2
Me.SectionID = calcsecid
End Function
I works great until I get to the RecCnt line. Can anyone please give me a clue? Thanks!