Sub works only in step mode (1 Viewer)

dcx693

Registered User.
Local time
Today, 11:53
Joined
Apr 30, 2003
Messages
3,265
It's been a while since I've been on the boards. Good to see lots of the same folks are still here. :D

I've got an interesting problem. I have a sub that calls another sub. Pretty simple there. The problem is that when sub A calls sub B, sub B does not appear to run. This is all sub B does:
Code:
If Not IsNull(Me.txtNumber) Then
    Me.txtNumber = Me.txtNumber + 1
End If
The weird thing is, sub B runs just fine if I run the sub B in step mode. If I set a break point and use F8 to step through the code line-by-line, it runs just fine. If I take out the breakpoint, the code no longer works.

Anybody have any ideas? I'm running Access XP Sp2 on Windows XP SP1. Thanks.
 

pafcpilgrim

Keeping it Green
Local time
Today, 16:53
Joined
Apr 14, 2005
Messages
36
There should be no reason it doesn't work the break point is there just to help us see how the code runs and what values are being set, so if it works fine when you use it there is no reason why it shouldn't when it runs through on it's own.

Try changing your code to the following just to make sure it will pick up and add the new value.

Code:
If Not IsNull(Me.txtNumber.value) Then
    Me.txtNumber.value = Me.txtNumber.value + 1
End If

There should be no other reason, depending on what Sub A does ass i don't know. Also do you need a seperate sub procedure just for that line of code too, don't complicate it if it's not needed??
 

dcx693

Registered User.
Local time
Today, 11:53
Joined
Apr 30, 2003
Messages
3,265
Thanks for the reply pafcpilgrim. I know there's no reason why the code should execute any differently - but that's exactly what's happening! :mad:

I tried the code using the .Value property, but as expected, it made no difference.

I've compacted and repaired the database with no change.

The reason sub B is separated out is that it's being called from one place on the form.
 

dcx693

Registered User.
Local time
Today, 11:53
Joined
Apr 30, 2003
Messages
3,265
I also tried inserting the code directly into sub A instead of calling it as a subroutine. Same thing. The code works in break mode, but won't work otherwise! :mad:
 

Users who are viewing this thread

Top Bottom