Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 April 19th, 2007, 11:29 AM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Call Standard Module Error Handler from From mod

Using Access 2003 - I've followed Denise's instructions in Beginning Access 2003 VBA exactly, as far as I can tell, but "it" doesn't work.

I have in a Standard Module [modBusinessLogic]:
_____________________________

' General Error Handler to be called from most procedures

Public Sub GenErrHand(lngErrNumber As Long, strErrDesc As String,
strModuleSource As String, strProcedureSource As String)

    Dim strMessage As String

    strMessage = "An error has occured. Please report this info:" & _
        vbCrLf & "Error Number: " & lngErrNumber & _
        vbCrLf & "Description: " & strErrDesc & _
        vbCrLf & "Module: " & strModuleSource & _
        vbCrLf & "Procedure: " & strProcedureSource

        MsgBox strMessage, vbCritical

End Sub
_________________________

I have in a Form's Module [Form_FA1_OrgMaster_All]:
_________________________
  Private Sub cboOrgs_AfterUpdate()

    On Error GoTo HandleError

         (((NOTE: the first subform name below is misspelled - not supposed to be ...FinRpt..., correct is ...FinRpts... - this sets up an error to test Error Handler)))

    Me.subfrmctrlFinRpt!cboIS_BySrv_List = Null
    Me.subfrmctrlFinRpts!cboIS_BySrv_List.Requery

                            ... More Code ...

    Exit Sub

HandleError:
    Dim strPrcdrName As String
    strPrcdrName = "cboOrgs_AfterUpdate"
    Dim strModName As String
    strModName = Application.CurrentObjectName

    Call GenErrHand(Err.Number, Err.Description, strModName, strPrcdrName)

    Exit Sub

  End Sub
_________________________
When I tested (with the Immediate Window) the Error Handler with a procedure in the Standard Module that would create an error (per Denise's instructions in Chap 2), it "worked". That is, it produced the Message Box I want.

But when I test it with the set up above (chosing an Organization in the Combo Box on the form), instead of getting the Message Box I want, I get "Compile Error: Method or data member not found" - which is obviously the regular VBA Message Box.

Why don't I get the Message Box from my Error Handler? Thanks

John D
 
Old April 19th, 2007, 03:43 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

1. GenErrHand() is a sub. Don't use "Call", and don't enclose arguments in parens.
    Call implies that you are discarding a Function’s return value.

2. You might be getting the error somewhere prior to this combo’s AfterUpdate event.
    Add a Form_Error() event to the form, and see if you wind up there prior to
    your combo’s event.
 
Old April 19th, 2007, 05:06 PM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian - I took out the "Call" per your suggestion, and removed the parentheses. I also put a "Sub Form_Error () Event Procedure to produce a custom Error Message Box as you suggested, but I didn't wind up there when I chose a new value in the Combo Box.

In addition to the "Compile Error:Method or data member not found" message I mentioned before, the yellow highlighted line in the Form's Module is "Private Sub cboOrgs-AfterUpdate() and the blue highlighted line is the misspelled form name ".subfrmctrlFinRpt".

Alas, it still doesn't "work". Thanks

 
Old April 20th, 2007, 07:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

Your problem is that you are not getting the error routine called because you are not even executing your program!
your error is not at runtime (that's where it use the error routine), but on compilation, so it's trapped by the compiler and showed to you...

the error you are receiving is the same that you want to receive at runtime, but it throwed by the IDE...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old April 20th, 2007, 01:53 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Oh... Yeah... [u]compile</u> error... (Doh!)

John, what line is highlighted when you get this error message.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference to a standard module Richard_Au_2008 Access VBA 3 November 4th, 2008 11:55 AM
Programmatically call onChange handler langdale Javascript How-To 1 September 3rd, 2007 09:24 AM
Call Standard Module Error Handler from Form mod johndickerson BOOK: Beginning Access 2003 VBA 0 April 19th, 2007 11:12 AM
Parse error in error handler (Chapter 8) Funky Monk BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 August 6th, 2004 08:59 AM





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