Hi
hope this is the right place for this topic. I am creating a staff attendance system through a listbox and a textbox which automates todays current date.
this is my dcount code
If (DCount("[StaffID]", _
"tblAttendance", _
"[StaffID] = " & Me.lstStaffAttendance & " And " & _
"[StaffFirstName] = " & Me.lstStaffAttendance & " AND " & _
"[AbsentDate] = #" & Me.txtTodaysDate & "#" & " or " & _
"[AttendDate] = #" & Me.txtTodaysDate & "#")) > 0 Then
MsgBox "This Employee Already Exists"
Cancel = True
Me!lstStaffAttendance.Undo
there is an error stating runtime error 3075, syntax error missing operator in query expression '[StaffID] = AND [StaffFirstName] = And [AbsentDate] = #01/02/2015# or [AttendDate] = #01/02/2015#. I know the error lies on staffID line because I removed other code lines and error started from there.
could someone please guide me, ive been working on this for so long I don't have a clue anymore. I think due to this error, the dcount does not prevent the duplication. this section of code below enable to add the information from listbox to table incase if you need it.
Set ctl = Me.lstStaffAttendance
Const StaffFirstName As String = 1
Const StaffSurname As String = 2
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!StaffID = ctl.Column(StaffID, varItem)
rs!StaffFirstName = ctl.Column(StaffFirstName, varItem)
rs!StaffSurname = ctl.Column(StaffSurname, varItem)
rs!WorkStarted = txtTimeIn
rs!WorkFinished = txtTimeOut
rs!AttendDate = txtTodaysDate
rs.Update
Next varItem
MsgBox "Done!"
thank you I really appreciate it