In what way does it now work? Is there an error message? In the line:
"where weekending = #" & [WeekEnding] & "# and recruiterid = " &
[RecruiterID] & ";"
how does weekending differ from [WeekEnding]? Same for RecruiterID.
Are you trying to change many records or just the current one? Are you
trying to accomplish through this code what could also be accomplished
through an update query? It's fine if you are, but there are certain syntax
rules you need to follow. If you can make this work through a query, post
the query's SQL.
I will need you to answer the questions in this post if I am to put any more
time into this. My guesses about what you need to do have been wrong so far.
If it is important to use DBEngine.Execute then you will need to start a new
thread. I am not familiar with that command. However, be advised that
whoever answers will probably ask as I have what you need to accomplish.
Saying that you need to update the table pretty much describes any data entry
or modification.
Venus said:
It still doesn't work.
The DBEngine works too if I put a break-point in the code and step thru it.
Thats the confusing thing. If I step thru the code it executes, If I just
run it without putting any breaks points, nothing happens.
BruceM said:
From your cryptic reply I gather you need to update all records that meet
certain criteria. I will further assume that the SQL statement works in an
update query, but not from a command button. Instead of DBEngine.Execute,
try:
Docmd.RunSQL strSql
You may need to requery if you need immediate results on the current record.
:
I need to update the employees table.
:
Is the idea to filter the recordset? If so, how about:
On Error Goto ProcErr
strsql = "UPDATE Employees INNER JOIN TimeSheets ON _
Employees.EmployeeID = TimeSheets.EmployeeID SET _
TimeSheets.RunComm = -1 " & "where weekending = #" & _
[WeekEnding] & "# and recruiterid = " & [RecruiterID] & ";"
Me.RecordSource = strSql
Me.Requery
ProcExit:
Exit Sub
ProcErr:
msgbox "Error #" & Err.Number & ", " & Err.Description
Resume ProcExit
:
Private Sub SelectAllbtn_Click()
Dim strsql As String
strsql = "UPDATE Employees INNER JOIN TimeSheets ON Employees.EmployeeID
= TimeSheets.EmployeeID SET TimeSheets.RunComm = -1 " & _
"where weekending = #" & [WeekEnding] & "# and recruiterid = " &
[RecruiterID] & ";"
DBEngine(0)(0).Execute strsql, dbFailOnError
End Sub
:
What is the procedure?
:
I have an event procedure on a command button.
The procedure does not execute unless I put a break point in the code.
It works when I step thru it, but if I remove the break point and click on
the button, nothing happens.
Any clues????