PC Review


Reply
Thread Tools Rate Thread

Access & warning trap

 
 
Vuillermet Jacques
Guest
Posts: n/a
 
      24th May 2004
With VBA, we can trap error with :

On Error ...

About the warnings, we can disabled them with :

DoCmd.SetWarnings False

But how to trap the warnings ?
On warning, I want to run specific code instead of showing the in-built
message box to the user.

Thanks.

Jacques.




 
Reply With Quote
 
 
 
 
solex
Guest
Posts: n/a
 
      24th May 2004
Jacques,

In the code where you want to trap the warnings issue the DoCmd.SetWarning
to True after the code is finished executing reset the warnings to False.

Regards,
Dan

"Vuillermet Jacques" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> With VBA, we can trap error with :
>
> On Error ...
>
> About the warnings, we can disabled them with :
>
> DoCmd.SetWarnings False
>
> But how to trap the warnings ?
> On warning, I want to run specific code instead of showing the in-built
> message box to the user.
>
> Thanks.
>
> Jacques.
>
>
>
>



 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      24th May 2004
"Vuillermet Jacques" <(E-Mail Removed)> wrote in
news:#(E-Mail Removed):

> DoCmd.SetWarnings False
>
> But how to trap the warnings ?
> On warning, I want to run specific code instead of showing the in-built
> message box to the user.
>


Depends on what you are doing at the time. Many of the macro commands have
proper database methods that you can call; for example, instead of

DoCmd.RunSQL

use

db.Execute strCommand, dbFailOnError

and get a normal vb Error. Similarly, force-saving a form can be achieved
with

Me.Dirty = False

rather than DoCmd.RunCommand and so on. If it's a database command, you can
do it with one of the ADO or DAO methods; for most of the GUI stuff you can
call the Forms() or Reports() methods or properties etc. I very rarely use
the DoCmd object; and when I do, I recognise it as a warning that I am
probably going the wrong way about something.

The biggest exception is DoCmd.OpenForm and .OpenReport, and that is
because DAO does not have a good way of manipulating the Forms() and
Reports() collections. The desired syntax would be something like

Forms.Add "frmPatientContacts", dbFormHidden
With Forms("frmPatientContacts")
.PatientID = 30458
.DateFrom = #2004-01-01#
.Requery
.Visible = True

End With

but we can't do that, so there.


All the best


Tim F

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to trap Excel Save from Access Chutney Microsoft Access 1 26th Aug 2009 03:54 PM
How To: Trap Access error message. =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV5?= Microsoft Access Form Coding 2 7th Aug 2006 04:31 PM
Trap access to registry key _DD Windows XP General 1 12th Jun 2006 07:48 AM
Trap/Answer Excel Messages from Access? LarryP Microsoft Access VBA Modules 2 28th May 2004 04:27 PM
How to trap when Access is closed Jerry Microsoft Access VBA Modules 1 20th May 2004 10:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:28 PM.