VBA Editor skips lines and moves to other part of code

B

BlueWolverine

Hello,
MS ACCESS 2003 on XP PRO.

I have a form checkbox, and AFTERUPDATE of the value, I run a bunch of code.
Part of the code calls a sub in a module. During this sub, I define two
string values. (they happen to be shaped like SQL statements but at this
point the computer doesn't know that) the first one runs fine, and the MSGBOX
statement after shows the text correctly.

However, when the yellow gets on top of the SECOND str_SQL = statement, and I
hit F8, the code skips OUT of the SUB, back to the AFTERUPDATE statement on
the line that would execute after the sub. This even happens when I just run
the thing with no break points. It's like Str_SQL = is function like EXIT
SUB.

What the heck is going on?

<<<
str_SQL1 = "UPDATE t_Plates SET t_Plates.CurrVIN = Null, t_Plates.Assigned =
False, t_Plates.Active = False " & _
"WHERE ((t_Plates.Plate)='" & in_PlateNo & "');"
MsgBox str_SQL1

[This is where it breaks]
str_SQL2 = "UPDATE t_PlateHistory SET t_PlateHistory.Unassigned
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments &
Chr(10) & "'Plate Deactivated at this time - '" & Now() & " " & _
"WHERE (((t_PlateHistory.Unassigned) Is Null) AND
((t_PlateHistory.Plate)='" & in_PlateNo & "') AND ((t_PlateHistory.VIN)='" &
in_VIN & "') AND ((t_PlateHistory.Assigned) Is Not Null));"
[It never gets to this msgbox statement]
MsgBox str_SQL2
 
S

Stuart McCall

BlueWolverine said:
Hello,
MS ACCESS 2003 on XP PRO.

I have a form checkbox, and AFTERUPDATE of the value, I run a bunch of
code.
Part of the code calls a sub in a module. During this sub, I define two
string values. (they happen to be shaped like SQL statements but at this
point the computer doesn't know that) the first one runs fine, and the
MSGBOX
statement after shows the text correctly.

However, when the yellow gets on top of the SECOND str_SQL = statement,
and I
hit F8, the code skips OUT of the SUB, back to the AFTERUPDATE statement
on
the line that would execute after the sub. This even happens when I just
run
the thing with no break points. It's like Str_SQL = is function like EXIT
SUB.

What the heck is going on?

<<<
str_SQL1 = "UPDATE t_Plates SET t_Plates.CurrVIN = Null, t_Plates.Assigned
=
False, t_Plates.Active = False " & _
"WHERE ((t_Plates.Plate)='" & in_PlateNo & "');"
MsgBox str_SQL1

[This is where it breaks]
str_SQL2 = "UPDATE t_PlateHistory SET t_PlateHistory.Unassigned
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments
&
Chr(10) & "'Plate Deactivated at this time - '" & Now() & " " & _
"WHERE (((t_PlateHistory.Unassigned) Is Null) AND
((t_PlateHistory.Plate)='" & in_PlateNo & "') AND ((t_PlateHistory.VIN)='"
&
in_VIN & "') AND ((t_PlateHistory.Assigned) Is Not Null));"
[It never gets to this msgbox statement]
MsgBox str_SQL2

Sounds like you have a form timer running. If so, "turn it off" with:

Forms!FormName.TimerInterval = 0

in the immediate window.
 
B

BlueWolverine

I tried that after you suggested it and it didn't work. HELP!!!!
--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!


Stuart McCall said:
BlueWolverine said:
Hello,
MS ACCESS 2003 on XP PRO.

I have a form checkbox, and AFTERUPDATE of the value, I run a bunch of
code.
Part of the code calls a sub in a module. During this sub, I define two
string values. (they happen to be shaped like SQL statements but at this
point the computer doesn't know that) the first one runs fine, and the
MSGBOX
statement after shows the text correctly.

However, when the yellow gets on top of the SECOND str_SQL = statement,
and I
hit F8, the code skips OUT of the SUB, back to the AFTERUPDATE statement
on
the line that would execute after the sub. This even happens when I just
run
the thing with no break points. It's like Str_SQL = is function like EXIT
SUB.

What the heck is going on?

<<<
str_SQL1 = "UPDATE t_Plates SET t_Plates.CurrVIN = Null, t_Plates.Assigned
=
False, t_Plates.Active = False " & _
"WHERE ((t_Plates.Plate)='" & in_PlateNo & "');"
MsgBox str_SQL1

[This is where it breaks]
str_SQL2 = "UPDATE t_PlateHistory SET t_PlateHistory.Unassigned
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments
&
Chr(10) & "'Plate Deactivated at this time - '" & Now() & " " & _
"WHERE (((t_PlateHistory.Unassigned) Is Null) AND
((t_PlateHistory.Plate)='" & in_PlateNo & "') AND ((t_PlateHistory.VIN)='"
&
in_VIN & "') AND ((t_PlateHistory.Assigned) Is Not Null));"
[It never gets to this msgbox statement]
MsgBox str_SQL2

Sounds like you have a form timer running. If so, "turn it off" with:

Forms!FormName.TimerInterval = 0

in the immediate window.


.
 
D

Dirk Goldgar

BlueWolverine said:
Hello,
MS ACCESS 2003 on XP PRO.

I have a form checkbox, and AFTERUPDATE of the value, I run a bunch of
code.
Part of the code calls a sub in a module. During this sub, I define two
string values. (they happen to be shaped like SQL statements but at this
point the computer doesn't know that) the first one runs fine, and the
MSGBOX
statement after shows the text correctly.

However, when the yellow gets on top of the SECOND str_SQL = statement,
and I
hit F8, the code skips OUT of the SUB, back to the AFTERUPDATE statement
on
the line that would execute after the sub. This even happens when I just
run
the thing with no break points. It's like Str_SQL = is function like EXIT
SUB.

What the heck is going on?

<<<
str_SQL1 = "UPDATE t_Plates SET t_Plates.CurrVIN = Null, t_Plates.Assigned
=
False, t_Plates.Active = False " & _
"WHERE ((t_Plates.Plate)='" & in_PlateNo & "');"
MsgBox str_SQL1

[This is where it breaks]
str_SQL2 = "UPDATE t_PlateHistory SET t_PlateHistory.Unassigned
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments
&
Chr(10) & "'Plate Deactivated at this time - '" & Now() & " " & _
"WHERE (((t_PlateHistory.Unassigned) Is Null) AND
((t_PlateHistory.Plate)='" & in_PlateNo & "') AND ((t_PlateHistory.VIN)='"
&
in_VIN & "') AND ((t_PlateHistory.Assigned) Is Not Null));"
[It never gets to this msgbox statement]
MsgBox str_SQL2


I wonder if you have error-handling in place that is transferring control
(somewhat oddly) after an error in the assignment statement. There's
something that looks wrong about the assignment to str_SQL2. This bit:
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments
&

.... looks fishy. What is the second "t_PlateHistory.Comments" referred to
there? I don't think there can be a control on your form with that name.
 
D

DrGUI

The Chr(10) looks suspicious to me. The fact that you don't have a matching
single quote for the t_PlateHistory.Comment also could be causing your
problem.

Remove the char(10) and add the missing single quote. See if that helps.

BlueWolverine said:
Hello,
MS ACCESS 2003 on XP PRO.

I have a form checkbox, and AFTERUPDATE of the value, I run a bunch of code.
Part of the code calls a sub in a module. During this sub, I define two
string values. (they happen to be shaped like SQL statements but at this
point the computer doesn't know that) the first one runs fine, and the MSGBOX
statement after shows the text correctly.

However, when the yellow gets on top of the SECOND str_SQL = statement, and I
hit F8, the code skips OUT of the SUB, back to the AFTERUPDATE statement on
the line that would execute after the sub. This even happens when I just run
the thing with no break points. It's like Str_SQL = is function like EXIT
SUB.

What the heck is going on?

<<<
str_SQL1 = "UPDATE t_Plates SET t_Plates.CurrVIN = Null, t_Plates.Assigned =
False, t_Plates.Active = False " & _
"WHERE ((t_Plates.Plate)='" & in_PlateNo & "');"
MsgBox str_SQL1

[This is where it breaks]
str_SQL2 = "UPDATE t_PlateHistory SET t_PlateHistory.Unassigned
= #" & Now() & "#, t_PlateHistory.Comments = '" & t_PlateHistory.Comments &
Chr(10) & "'Plate Deactivated at this time - '" & Now() & " " & _
"WHERE (((t_PlateHistory.Unassigned) Is Null) AND
((t_PlateHistory.Plate)='" & in_PlateNo & "') AND ((t_PlateHistory.VIN)='" &
in_VIN & "') AND ((t_PlateHistory.Assigned) Is Not Null));"
[It never gets to this msgbox statement]
MsgBox str_SQL2
 

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