Folks
In my system users enter their timesheet weekly. It seems that on the first week of every month the following code falls over. Returning a Runtime Error 3021 'No Current Record'
On the subform itself the following code exists within OnCurrent Property
Other than that there's also a instruction within the OnOpen property
All/any help greatly appreciated.
Thanks
Frank
In my system users enter their timesheet weekly. It seems that on the first week of every month the following code falls over. Returning a Runtime Error 3021 'No Current Record'
Code:
Option Compare Database
Function GetFlexiMax(FDate As Date, FId As IdleEnum, Username As String, Maxlimit As Long)
Dim Rs1 As Recordset
Dim StrSql As String
StrSql = "SELECT QRY_FlexiByWeekwithRN.* FROM QRY_FlexiByWeekwithRN WHERE (((QRY_FlexiByWeekwithRN.xDate)<=#" & FDate & "#) AND ((QRY_FlexiByWeekwithRN.IDRN)<=" & FId & ") AND ((QRY_FlexiByWeekwithRN.Username)='" & Username & "'));"
GetFlexiMax = 0
Set Rs1 = CurrentDb.OpenRecordset(StrSql)
Rs1.MoveFirst
Do While Not Rs1.EOF
GetFlexiMax = IIf(Rs1!SuplusTime + GetFlexiMax > Maxlimit, Maxlimit, Rs1!SuplusTime + GetFlexiMax)
Rs1.MoveNext
Loop
Rs1.Close
Set Rs1 = Nothing
End Function
On the subform itself the following code exists within OnCurrent Property
Code:
Private Sub Form_Current()
If NewRecord Then
FlexiMax = 0
Else
FlexiMax = GetFlexiMax([xDate], [IDRN], [Username], 864)
End If
End Sub
Other than that there's also a instruction within the OnOpen property
Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
End Sub
All/any help greatly appreciated.
Thanks
Frank