L
Lin
Hello and thank you
I had code from one fellow to help with my problem. I needed to be able to
Count each new record (form) over a month period and restart from 1 each
month.
The code I was given works fine for a while then something happens it just
stops advancing. This has been happening for some time both on my test
database and work database.
Here is the code:
Private Sub AdmitDate_BeforeUpdate(Cancel As Integer)
Dim MaxIdx, Criteria As String
Dim namIdx As String, namDate As String, namTable As String
If Me.NewRecord Then
namDate = "AdmitDate"
namIdx = "AdmitNum"
namTable = "tblAdmit"
Criteria = "Month([" & namDate & "]) = " & Month(Me(namDate)) & " And "
& "Year([" & namDate & "]) = " & Year(Me(namDate))
MaxIdx = DMax("[" & namIdx & "]", namTable, Criteria)
If IsNull(MaxIdx) Then
Me(namIdx) = 1 'Start over on new month & year
Else
Me(namIdx) = MaxIdx + 1
End If
End If
End Sub
Can anyone figure out why?
Thanks
I had code from one fellow to help with my problem. I needed to be able to
Count each new record (form) over a month period and restart from 1 each
month.
The code I was given works fine for a while then something happens it just
stops advancing. This has been happening for some time both on my test
database and work database.
Here is the code:
Private Sub AdmitDate_BeforeUpdate(Cancel As Integer)
Dim MaxIdx, Criteria As String
Dim namIdx As String, namDate As String, namTable As String
If Me.NewRecord Then
namDate = "AdmitDate"
namIdx = "AdmitNum"
namTable = "tblAdmit"
Criteria = "Month([" & namDate & "]) = " & Month(Me(namDate)) & " And "
& "Year([" & namDate & "]) = " & Year(Me(namDate))
MaxIdx = DMax("[" & namIdx & "]", namTable, Criteria)
If IsNull(MaxIdx) Then
Me(namIdx) = 1 'Start over on new month & year
Else
Me(namIdx) = MaxIdx + 1
End If
End If
End Sub
Can anyone figure out why?
Thanks