• Error handler (97)

    Author
    Topic
    #375446

    Error handler

    Set qd = db.CreateQueryDef(“qryDtlMgrMth” & i, “SELECT tblPromotionType.promotionType, Manager.Code, Manager.DirectorCode, tblYear.Year, tblMonth.Month, tblMonth.MonthName, Manager.ManagerName FROM Manager, tblMonth, tblPromotionType, tblYear GROUP BY tblPromotionType.promotionType, Manager.Code, Manager.DirectorCode, tblYear.Year, tblMonth.Month, tblMonth.MonthName, Manager.ManagerName ORDER BY tblPromotionType.promotionType, Manager.Code, Manager.DirectorCode, tblMonth.Month;”)

    errorHandler:
    Select Case err.number
    ‘qry exists already…
    Case 3012
    Exit Sub
    End Select

    The above SET statement creates error 3012 when i try to create my query definition. As such I created the ERROR HANDLER statement just above as well. Problem is when the error occurs, nothing happens, the ERROR HANDLER does not receive control of the flow at this point, why is this? Please note that the SET statement does appear within a SELECT CASE statement nested within a FOR loop which itself occurs within another SELECT CASE statement.

    Viewing 1 reply thread
    Author
    Replies
    • #611078

      When you say nothing happens, are you saying you don’t get a message, or what? As it stands, your program will exit the subroutine without any messages whenever there is an error (any error). How do you know it’s not getting to your error handler?

      If you want to see messages for other errors when you have an error handler, you need to explicitly output them with, e.g.
      msgbox err.number & ” ” & err.description
      (I like showing the number – makes it easier to look up weird errors).

    • #611097

      Did you remember to put “On Error Goto ErrorHandler” in your routine?

    Viewing 1 reply thread
    Reply To: Error handler (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: