Hello,
when running the below code the expression "WeekdayName(Weekday(strIn, 2), True, 2)" is causing the following error: "Microsoft Access can't find the field 'Weekday' referred to in your expression."
I use exactly the same expression in 2 other forms in this database without any issues and just can't figure out what this problem is in this case.
Any assistance would be much appreciated.
Private Sub Quick_Log_In()
Dim db As DAO.Database
Dim rsTimeSheet As DAO.Recordset
Dim strWorkingCode, strYear, strMonth, strWeekNbr, strWeekday, strIn As String
On Error GoTo Err_Quick_Log_In
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
strWorkingCode = DLookup("[Default working code]", "tblEmployee", "[Name] = """ & strEmployee & """")
strEmployer = DLookup("[Employer]", "tblEmployee", "[Name] = """ & strEmployee & """")
strIn = Me.In
strTSRecID = Me.ID
strYear = DatePart("yyyy", strIn, 2, 2)
strMonth = DatePart("m", strIn, 2, 2)
strWeekNbr = DatePart("ww", strIn, 2, 2)
'########## Weekday expression issue ##########
strWeekday = WeekdayName(Weekday(strIn, 2), True, 2)
'########## Weekday expression issue ##########
If Len(strMonth) < 2 Then
strMonth = "0" & strMonth
End If
If Len(strWeekNbr) < 2 Then
strWeekNbr = "0" & strWeekNbr
End If
Set db = CurrentDb()
Set rsTimeSheet = db.OpenRecordset("tblTimeSheetRecords", dbOpenDynaset)
If Not (rsTimeSheet.EOF = True And rsTimeSheet.BOF = True) Then
rsTimeSheet.MoveFirst
rsTimeSheet.FindFirst "[ID] =" & strTSRecID
rsTimeSheet.Edit
rsTimeSheet("Employee") = strEmployee
rsTimeSheet("Employer") = strEmployer
rsTimeSheet("Working code") = strWorkingCode
rsTimeSheet("In") = strIn
rsTimeSheet("Hours") = 0
rsTimeSheet("Hrs") = "0"
rsTimeSheet("Mins") = "00"
rsTimeSheet("Week day") = strWeekday
rsTimeSheet("Week number") = strWeekNbr
rsTimeSheet("Month") = strMonth
rsTimeSheet("Year") = strYear
rsTimeSheet.Update
rsTimeSheet.Close
Set rsTimeSheet = Nothing
End If
Exit_Quick_Log_In:
Exit Sub
Err_Quick_Log_In:
MsgBox Err.Description
Resume Exit_Quick_Log_In
End Sub
when running the below code the expression "WeekdayName(Weekday(strIn, 2), True, 2)" is causing the following error: "Microsoft Access can't find the field 'Weekday' referred to in your expression."
I use exactly the same expression in 2 other forms in this database without any issues and just can't figure out what this problem is in this case.
Any assistance would be much appreciated.
Private Sub Quick_Log_In()
Dim db As DAO.Database
Dim rsTimeSheet As DAO.Recordset
Dim strWorkingCode, strYear, strMonth, strWeekNbr, strWeekday, strIn As String
On Error GoTo Err_Quick_Log_In
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
strWorkingCode = DLookup("[Default working code]", "tblEmployee", "[Name] = """ & strEmployee & """")
strEmployer = DLookup("[Employer]", "tblEmployee", "[Name] = """ & strEmployee & """")
strIn = Me.In
strTSRecID = Me.ID
strYear = DatePart("yyyy", strIn, 2, 2)
strMonth = DatePart("m", strIn, 2, 2)
strWeekNbr = DatePart("ww", strIn, 2, 2)
'########## Weekday expression issue ##########
strWeekday = WeekdayName(Weekday(strIn, 2), True, 2)
'########## Weekday expression issue ##########
If Len(strMonth) < 2 Then
strMonth = "0" & strMonth
End If
If Len(strWeekNbr) < 2 Then
strWeekNbr = "0" & strWeekNbr
End If
Set db = CurrentDb()
Set rsTimeSheet = db.OpenRecordset("tblTimeSheetRecords", dbOpenDynaset)
If Not (rsTimeSheet.EOF = True And rsTimeSheet.BOF = True) Then
rsTimeSheet.MoveFirst
rsTimeSheet.FindFirst "[ID] =" & strTSRecID
rsTimeSheet.Edit
rsTimeSheet("Employee") = strEmployee
rsTimeSheet("Employer") = strEmployer
rsTimeSheet("Working code") = strWorkingCode
rsTimeSheet("In") = strIn
rsTimeSheet("Hours") = 0
rsTimeSheet("Hrs") = "0"
rsTimeSheet("Mins") = "00"
rsTimeSheet("Week day") = strWeekday
rsTimeSheet("Week number") = strWeekNbr
rsTimeSheet("Month") = strMonth
rsTimeSheet("Year") = strYear
rsTimeSheet.Update
rsTimeSheet.Close
Set rsTimeSheet = Nothing
End If
Exit_Quick_Log_In:
Exit Sub
Err_Quick_Log_In:
MsgBox Err.Description
Resume Exit_Quick_Log_In
End Sub