I'm using DLookup for the first time and trying to wrap my brain around how it works and the syntax involved.
I want to basically append a table using a form.
Dim chgreqrec As Recordset
Set chgreqrec = CurrentDb.OpenRecordset("AttendanceEvents")
chgreqrec.AddNew
chgreqrec![Event Date] = txtPersonalDate
chgreqrec![Employee] = Employee
chgreqrec![EventTypeCode] = "P"
The code above runs fine. On the code below, I'm getting a type mismatch error. I have an option box where 1 signifies a full personal day and 2 & 3 are half days (am or pm). I want the start time to be the employee's scheduled start time for that particular day, which is held in tblSchedules. I want to report start time where the employee column in the table matches the employee listed on the form and then I want the start time for the correct day for that employee.
If opFullHalf = 1 Or opFullHalf = 2 Then
chgreqrec![StartTime] = DLookup("[tblSchedules].StartTime", "[tblSchedules].Employee = " & Employee And "[tblSchedules].Day = " & txtWeekDay)
Help with the code and and further tips (in English please) about using this function would be appreciated!
I want to basically append a table using a form.
Dim chgreqrec As Recordset
Set chgreqrec = CurrentDb.OpenRecordset("AttendanceEvents")
chgreqrec.AddNew
chgreqrec![Event Date] = txtPersonalDate
chgreqrec![Employee] = Employee
chgreqrec![EventTypeCode] = "P"
The code above runs fine. On the code below, I'm getting a type mismatch error. I have an option box where 1 signifies a full personal day and 2 & 3 are half days (am or pm). I want the start time to be the employee's scheduled start time for that particular day, which is held in tblSchedules. I want to report start time where the employee column in the table matches the employee listed on the form and then I want the start time for the correct day for that employee.
If opFullHalf = 1 Or opFullHalf = 2 Then
chgreqrec![StartTime] = DLookup("[tblSchedules].StartTime", "[tblSchedules].Employee = " & Employee And "[tblSchedules].Day = " & txtWeekDay)
Help with the code and and further tips (in English please) about using this function would be appreciated!