Event procedure does not execute without break point?????

V

Venus

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????
 
V

Venus

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
 
B

BruceM

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

Venus said:
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


BruceM said:
What is the procedure?
 
V

Venus

I need to update the employees table.

BruceM said:
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

Venus said:
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


BruceM said:
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????
 
B

BruceM

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.

Venus said:
I need to update the employees table.

BruceM said:
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

Venus said:
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????
 
V

Venus

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.

Venus said:
I need to update the employees table.

BruceM said:
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????
 
B

BruceM

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.

Venus said:
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????
 
V

Venus

Thanks so much for your time and effort but it works now.
The problem was that the previous item was not losing the focus.
Its wierd because when I click on the command button, it should
automatically set the focus to it. But when I did it explicitly by using
"set focus" in a macro, it started working.
Strange but it works!!
Thanks again.

BruceM said:
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????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top