473,738 Members | 10,643 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 3876
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
3377
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
4751
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
6899
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
4483
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
5832
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
2183
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
19484
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
7606
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
8969
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
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
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...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.