RunSQL Update

MS_Access_Amature

Registered User.
Local time
Today, 04:59
Joined
Nov 10, 2010
Messages
56
I have a form with a listEmployees (listbox), a ButtonPunchIn, and a ButtonPunchOut.

When I select an employee from the listbox and click ButtonPunchIn the date and time saves in the EmployeesT. When I click ButtonClockOut I want it to update the selected employee in the list box. Can some please help me. I have this code but is not working.

private sub btnClockOut_click()

docmd.runsql "update EmployeeT set TimeOut=Now() where employeeId=" & me.employeeid

end sub
 
Use this instead (and avoid RunQuery):

Code:
CurrentDb.Execute "Update EmployeeT set TimeOut=#" & Now() & "# where employeeId=" & me.employeeid, dbFailOnError
 
Can you explain whats wrong with the "RunQuery" method Bob?

Just wondering
 
Can you explain whats wrong with the "RunQuery" method Bob?

Just wondering
Message box - "You are about to update 1 record...blah, blah, blah.

you get messages asking if you want to do this and that you will be updating x number of records. The CurrentDb.Execute method allows you to avoid those without setting Warnings to False.
 
I put the code in and i get Run-time error '3075': Syntax error (missing operator) in query expression 'employeeId='.


This is what I have:

Private Sub ButtonPunchOut_Click()
CurrentDb.Execute "Update EmployeeT set TimeOut=#" & Now() & "# where employeeId=" & Me.EmployeeID, dbFailOnError
End Sub
 
1. Is EmployeeID a text or numeric field?

2. Are you sure you have the bound column of the control (I assume a combo box) set to the correct column where the EmployeeID falls in the query? So, if it is in the third column, the bound column is 3. And the column Count is set to the number of fields in the query.

From the look of your error message it looks like there is a null value being returned by the control on your form.
 

Users who are viewing this thread

Back
Top Bottom