Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2003, 09:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default Code Execution Stops for No Known Reason

I have a section of VBA code in MS-Access, that for reasons I don't understand, stops the execution of the code and leaves the user looking at a yellow highlighted line of code in the VBE. The code looks like the following:


On Error Resume Next
Set MyForm = Forms("MyForm")
LastError = Err ' <=== Stops HERE

If LastError <> 0 Then
    ... blah, blah, blah

I am using the error condition to find out if the form "My Form" is opened.

     At first, I had "Stop on All Errors" checked. When I was done debugging, I switched to "Stop on UnHandled Errors". The code worked fine for several weeks. Now it stops at the point indicated. When I check the value of Err (Immediate Window: ?Err.Number), I get zero.

I am baffled as to why this is happening. Does anyone have any ideas?

--- Tom


--- Tom
__________________
--- Tom
 
Old October 27th, 2003, 10:27 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What data type is LastError?

show complete code
You may be doing something else somewhere else that is causing the error at that point.


What have you changed lately?




Sal
 
Old October 27th, 2003, 10:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default

LastError is a variant.

Unfortunately, I have the complete code at work on a private network with no Internet access. The code I show is fairly consistent with what I have at work. I'll try to get a printout and post it.

I had not changed anything in the last 3 weeks.


--- Tom
 
Old October 27th, 2003, 11:01 PM
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have seen this before in an application I built. The code would just stop for no reason and display a yellow line of code to the end user. I set a break point in the proc and then F8'ed through the proc, clear all breakpoints and then pressed F5. I tested the proc again and then it didn't stop. I also ensured that is was compiled and I clicked save after the compile.

HTH,
Mike
 
Old October 27th, 2003, 11:31 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks ... I'll try that.


--- Tom
 
Old October 27th, 2003, 11:37 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do the de-compile and compact and repair that we talked about on this tread

http://p2p.wrox.com/topic.asp?TOPIC_ID=5188

then wee will see how it goes.





Sal
 
Old October 28th, 2003, 04:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

If I'm not mistaken, if you want to trap the error number you must use the Err.Number property, not just Err by itself. If you wanted a description of the error, you'd use Err.Description to get it.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Proc execution failed from CS code nkrust ASP.NET 2.0 Professional 0 August 30th, 2007 01:28 AM
Request Code Execution Permission Problem dparsons C# 0 May 14th, 2007 09:28 AM
"what is the reason" heerajee Oracle 1 March 24th, 2006 05:52 AM
Code stops responding when breakpoints added jaucourt VB.NET 2002/2003 Basics 0 September 2nd, 2004 03:40 AM
Run-time code execution module0000 Beginning VB 6 1 June 20th, 2003 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.