<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: [AccessD] A2K: On error goto next</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Instead of using on error I use this format in the exit section:</FONT>
<BR><FONT SIZE=2>If Not (rstLookup Is Nothing) Then rstLookup.Close: Set rstLookup = Nothing</FONT>
<BR><FONT SIZE=2>Jim Hale</FONT>
</P>
<BR>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Steven W. Erbach [<A HREF="mailto:serbach@new.rr.com">mailto:serbach@new.rr.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Monday, July 07, 2003 10:05 AM</FONT>
<BR><FONT SIZE=2>To: AccessD@databaseadvisors.com</FONT>
<BR><FONT SIZE=2>Subject: [AccessD] A2K: On error goto next</FONT>
</P>
<BR>
<P><FONT SIZE=2>Dear Group,</FONT>
</P>
<P><FONT SIZE=2>I've used the D-Function replacements created by T. Best for some time. I</FONT>
<BR><FONT SIZE=2>have an A2K application that has been churning along for a couple of years</FONT>
<BR><FONT SIZE=2>using these functions with nary a quiver.</FONT>
</P>
<P><FONT SIZE=2>Today, however, when I wanted to capture some screen shots, I went to run</FONT>
<BR><FONT SIZE=2>the application and it debugged at the first use of one of those D-Function</FONT>
<BR><FONT SIZE=2>replacements. Here's the pertinent section of code:</FONT>
</P>
<P><FONT SIZE=2>Function tCount(.....)</FONT>
<BR><FONT SIZE=2> ...(Dim statements and code for the body of the function)</FONT>
<BR><FONT SIZE=2> rstLookup.Close</FONT>
<BR><FONT SIZE=2> tCount = lngCount</FONT>
</P>
<P><FONT SIZE=2>tCountExit:</FONT>
<BR><FONT SIZE=2> On Error Goto Next</FONT>
<BR><FONT SIZE=2> rstLookup.Close</FONT>
<BR><FONT SIZE=2> Exit Function</FONT>
<BR><FONT SIZE=2>tCountError:</FONT>
<BR><FONT SIZE=2> msgBox ...</FONT>
<BR><FONT SIZE=2> Resume tCountExit</FONT>
</P>
<P><FONT SIZE=2>As you can see, just before the tCountExit subroutine the function closes a</FONT>
<BR><FONT SIZE=2>RecordSet and sets the value of the function to a Long Integer value</FONT>
<BR><FONT SIZE=2>calculated in the body of the function. The tCountExit subroutine tries to</FONT>
<BR><FONT SIZE=2>be neat and tidy about cleaning up the rstLookup RecordSet object variable</FONT>
<BR><FONT SIZE=2>just in case there's been an error in the body of the function.</FONT>
</P>
<P><FONT SIZE=2>Here's the problem: the tCount fuction closes the rstLookup object and does</FONT>
<BR><FONT SIZE=2>its thing properly by assigning a Long Integer value to the tCount function.</FONT>
<BR><FONT SIZE=2>Code execution drops into the tCountExit subroutine just as it should...but</FONT>
<BR><FONT SIZE=2>the app debugs at the rstLookup.Close instruction right after the On Error</FONT>
<BR><FONT SIZE=2>Goto Next. It's as if Access doesn't even "see" the Goto Next.</FONT>
</P>
<P><FONT SIZE=2>I've decompiled the application but the same error occurs. I finally</FONT>
<BR><FONT SIZE=2>commented out the rstLookup.Close in the tCountExit subroutine and</FONT>
<BR><FONT SIZE=2>everything flies just fine...but this code has been running without a hitch</FONT>
<BR><FONT SIZE=2>for two years or so. Any ideas? It beats my pair of Jacks.</FONT>
</P>
<P><FONT SIZE=2>Regards,</FONT>
</P>
<P><FONT SIZE=2>Steve Erbach</FONT>
<BR><FONT SIZE=2>Scientific Marketing</FONT>
<BR><FONT SIZE=2>Neenah, WI</FONT>
</P>
<BR>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>AccessD mailing list</FONT>
<BR><FONT SIZE=2>AccessD@databaseadvisors.com</FONT>
<BR><FONT SIZE=2><A HREF="http://databaseadvisors.com/mailman/listinfo/accessd" TARGET="_blank">http://databaseadvisors.com/mailman/listinfo/accessd</A></FONT>
<BR><FONT SIZE=2>Website: <A HREF="http://www.databaseadvisors.com" TARGET="_blank">http://www.databaseadvisors.com</A></FONT>
</P>
</BODY>
</HTML>