G
Guest
Hi there!
I have a continuous form that is used to enter data on the work done by
employees on a certain day. The user enters the EmployeeID, WorkDate,
HoursWorked,WorkID in text fields (This form is bounded to a table named Work)
When the user enters an employeeID, I want the program to check in the table
Employee to see if he exists. If he doesn't exist, a msgbox appears to advise
the user.
I have read many posts to help me design my code, but I can't make it work
properly. It works sometimes but I almost always get Syntax error (missing
operator) This happens when I go in the last line (for entering new data)
Here is my code:
Some parts are in french, sorry
Employee is also the name of the textbox in the form
Private Sub Employee_LostFocus()
Dim message, msg, title As String
msg = "Aucun n'employé n'a ce numéro. Veuillez le changer avant de changer
de ligne...(Sinon ça ne marchera pas et cette ligne ne s'affichera pas dans
la paie)"
title = "Erreur"
If DCount("EmployeeID", "Employee", "EmployeeID = " & Me.Employee) = 0
Then
message = MsgBox(msg, vbExclamation, title)
End If
End If
End Sub
----------------------------
I tried to put and if statement before the dcount like someone proposed in
another post but it didn't work. It just ignored the dcount. This is what i
tried:
if me.newrecord then
exit sub
else
my code ...
end if
I also tried somethig similar with Dlookup and didn't work either
Can someone please help me
Thanks a lot
Louis Pat
I have a continuous form that is used to enter data on the work done by
employees on a certain day. The user enters the EmployeeID, WorkDate,
HoursWorked,WorkID in text fields (This form is bounded to a table named Work)
When the user enters an employeeID, I want the program to check in the table
Employee to see if he exists. If he doesn't exist, a msgbox appears to advise
the user.
I have read many posts to help me design my code, but I can't make it work
properly. It works sometimes but I almost always get Syntax error (missing
operator) This happens when I go in the last line (for entering new data)
Here is my code:
Some parts are in french, sorry
Employee is also the name of the textbox in the form
Private Sub Employee_LostFocus()
Dim message, msg, title As String
msg = "Aucun n'employé n'a ce numéro. Veuillez le changer avant de changer
de ligne...(Sinon ça ne marchera pas et cette ligne ne s'affichera pas dans
la paie)"
title = "Erreur"
If DCount("EmployeeID", "Employee", "EmployeeID = " & Me.Employee) = 0
Then
message = MsgBox(msg, vbExclamation, title)
End If
End If
End Sub
----------------------------
I tried to put and if statement before the dcount like someone proposed in
another post but it didn't work. It just ignored the dcount. This is what i
tried:
if me.newrecord then
exit sub
else
my code ...
end if
I also tried somethig similar with Dlookup and didn't work either
Can someone please help me
Thanks a lot
Louis Pat