473,598 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error trapping in Access 2003

I'm still using Office 2000 myself, but some of my clients have Office 2003.
I've recently added a piece of code to create an instance of Word, open a
document, fill in the blanks and become visible so the document can be
printed and/or modified.

This all takes place within one form, in which the Word.Applicatio n and
Word.Document objects are both private form-level variables. Just to be on
the safe side I included this piece of code in the Form_Close() event
procedure:

On Error Resume Next
doc.Close wdDoNotSaveChan ges
app.Quit
Set doc = Nothing
Set app = Nothing

This all works fine in Access 2000 - if the objects are no longer set the
error trapping deals with it silently.

However, in Access 2003 it behaves exactly as if the 'On Error Resume Next'
were not there. In fact it seems to be the beyond reach of any kind of
error trapping code whatsoever!

Can anyone tell me whether this is a bug or a feature - and whichever it is,
how do I deal with it?

Thanks.
May 15 '06 #1
2 3868
Captain Nemo wrote in message
<F3************ ******@text.new s.blueyonder.co .uk> :
I'm still using Office 2000 myself, but some of my clients have
Office 2003. I've recently added a piece of code to create an
instance of Word, open a document, fill in the blanks and become
visible so the document can be printed and/or modified.

This all takes place within one form, in which the Word.Applicatio n
and Word.Document objects are both private form-level variables.
Just to be on the safe side I included this piece of code in the
Form_Close() event procedure:

On Error Resume Next
doc.Close wdDoNotSaveChan ges
app.Quit
Set doc = Nothing
Set app = Nothing

This all works fine in Access 2000 - if the objects are no longer set
the error trapping deals with it silently.

However, in Access 2003 it behaves exactly as if the 'On Error Resume
Next' were not there. In fact it seems to be the beyond reach of any
kind of error trapping code whatsoever!

Can anyone tell me whether this is a bug or a feature - and whichever
it is, how do I deal with it?

Thanks.


My first guess, would be the setting for error trapping. In VBE - Tools
| Options - General Tab - make sure it's set to Break on Unhandled
Errors.

--
Roy-Vidar
May 15 '06 #2
"RoyVidar" <ro************ *@yahoo.no> wrote in message
news:mn******** *************** @yahoo.no...
My first guess, would be the setting for error trapping. In VBE - Tools
| Options - General Tab - make sure it's set to Break on Unhandled
Errors.


Interesting point. Given that the Tools -> Options submenu is
"grayed out" until you load a database, I had assumed that this
meant that all options were saved with the .mdb file. That and
the fact that at least one option (Compact On Close) most
definitely IS saved with the database.

However, I was wrong about this. In fact, this is one of the
murkiest and worst-documented features of Access. For instance,
in the online help page "Set Options from Visual Basic" there is
a note at the bottom of the page advising the developer to set
Error Trapping to 2, when a project is completed. However, the
fact that "Error Trapping" does NOT appear in the list of Options
that may be set from VBA code further reinforces the myth that
such settings are saved with the .mdb file. The inference is that
as long as you manually set the Error Trapping to "Break on
Unhandled Errors" before you send the file off to the customer,
all will be well...

However, the good news is that this is nothing to do with Access
2003 (there are some peculiar bugs in that edition but this is not
one of them).

And the moral of this story is: ALWAYS make sure that the
Form_Open() event procedure of your startup form contains this line:

Application.Set Option "Error Trapping", 2

May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3364
by: Pete | last post by:
I'm trying to improve my code so that when I open a recordset object, I can absolutely guarantee it is closed and is set = Nothing. I have read some old threads and they all say to use the functional equivalent of the following code: Public Sub CloseRecordset() On Error GoTo Sub_Error Dim rs As Recordset rs.FindFirst "This Will Error"
6
4732
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
3
6879
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
13
4461
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently runs into problems on the system where it will actually be used, and since I used so little error-trapping it dies very ungracefully. I will of course try to fix whatever is causing the error and add error-trapping to the functions where the...
3
5819
by: Rolan | last post by:
I seem to be unable to have a custom error message to appear for Error 10011 (database was unable to append all the data to the table). Each time, the MS Access default error message box appears. The reason for the error is to prevent an import of a record of which one already exists based on a like item number. I tried various methods of structuring an error handler in the sub, including Select Case, but with no success. I assume that...
2
2166
by: Bill Stock | last post by:
I have a subform which is causing a 3314 (Field can't contain a null value because required is set to True) error. I solved this problem by trapping it in the before update event. But then I started getting a "No Current Record" error. I wanted to see what err number was coming through, so I put a MsgBox in the subform's error event. But the MsgBox never came up and the error is now gone. Is the MsgBox pulling the focus away from the...
2
19443
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
4
7597
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to an excel spreadsheet. There are two tables. One is a list of general contacts, and the other is a list of clubs. The clubs contain members who are within the contacts table. When I add a list of new club members from the
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
7981
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8284
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8262
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6711
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3894
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2410
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1500
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.