Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2004
    Location
    Rio Bravo, Mexico
    Posts
    27

    Unanswered: Need error routine

    Hello guys, need some help form anybody out there.

    I need a routine that can catch an error that I have not found a way to keep it from appearing. (See attatched pic). The developed application is in Spanish but the error is in English, check the attached link so you'll now what I mean.

    The error is generated when the user clicks on the 'Create Order' (See pick cirlced button) positions the cursor on the empy list button and instead of typing the pacients name, the user goes for close button to extit the form.
    If the user only clicks on the Create Orden and goes for the close button, the close action continues without a problem.

    I understand the meassage and I know why is generated, just need a way to catch it and let the user close the form with out the meassage. Right now in order to exit the form under this condition the user has to press ESC key sevetal times which in practical terms, this is not acceptable.

    Thanks for sharing your knowledge.
    Carlos
    Attached Thumbnails Attached Thumbnails Error.JPG  

  2. #2
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    Maybe this is a help :

    You can use the On Error GoTo statement to trap errors and direct procedure flow to the location of error-handling statements within a procedure. For example, the following statement directs the flow to the ErrorHandler: label line:

    On Error GoTo ErrorHandler

    Be sure to give each error handler label in a procedure a unique name that will not conflict with any other element in the procedure, and make sure you append a colon to the name. Within the procedure, place the Exit Sub or Exit Function statement in front of the error handler label so that the procedure doesn't run the error-checking code if no error occurs.

    Sub CausesAnError()
    ' Direct procedure flow.
    On Error GoTo ErrorHandler
    ' Raise division by zero error.
    Err.Raise 11
    Exit Sub

    ErrorHandler:
    ' Display error information.
    MsgBox "Error number " & Err.Number & ": " & Err.Description
    ' Resume with statement following occurrence of error.
    Resume Next
    End Sub

    The Raise method of the Err object generates the specified error. The Number property of the Err object returns the number corresponding to the most recent run-time error; the Description property returns the corresponding message text for a given error.

  3. #3
    Join Date
    Sep 2004
    Location
    Rio Bravo, Mexico
    Posts
    27
    Thanks Emiel for taking the time to respond to my question and thanks for explaining the Error handling routine. The problem here is that I have not been able find the right event and the right routine.

    I have tried all possible ways (within my limited knowledge ofcourse) to catch this specifc error. I have no problems setting up error routines, but this one is giving me a headache.

    If you try to recreate the error you will see what I mean.
    Just set up a form with a (New record) button and create a dropdown list, then if you click on create button, then position the cursor on the list field,
    (dont type anything) then try to exit the form, it is here that the error appears.
    Now if you just click on the "Create new record" button and then exit the form, it exits the form just fine. Its when you position the cursor on the drop down list and try to exit when the error appears.

    Any idea in what event the routine will go into, I tried Form events and List events.

    Thanks anyway
    Carlos

  4. #4
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    is there a ON EXIT event, or some other, attached to the dropdown list, it looks to me that if you leave the dropdown that some code is trying to locate the 'selected' item of the dropdown, which is empty, in your table tblPacientes, so i can suggest that you create an event (for instance ON EXIT) and check there the value of the dropdownlist something like this


    IF isNull(me!dropdownlist) OR len(trim(me!dropdown)) = 0
    exit sub
    else
    .........
    endif

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    are you doing this to yourself?

    i know i'm A2K and you are something later, but your "error" message looks like a msgbox. the normal dialog after an untrapped error (in A2K at least) looks like the attached .gif

    have you already successfully trapped the error, and now you are battling through your own error handler code?

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    the small-print from end of help on errors:

    Note System errors during calls to Windows dynamic-link libraries (DLL) or Macintosh code resources do not raise exceptions and cannot be trapped with Visual Basic error trapping. When calling DLL functions, you should check each return value for success or failure (according to the API specifications), and in the event of a failure, check the value in the Err object's LastDLLError property.

    it's possible that your jet error falls into this untrappable class - sorry i can't duplicate your error 'cos i don't do forms your way.

    if i execute garbage NewRecord SQL e.g.
    strSQL = "INSERT INTO tblNotThere (fieldNotThere) VALUES (1234);
    docmd.runsql strSQL
    (which is my way of doing NewRecord) it raises (trappable)
    runtime error 3192 cant find output table 'tblNotThere'
    in the normal error dialog.

    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Sep 2004
    Location
    Rio Bravo, Mexico
    Posts
    27
    Thanks Emial, Izy. I do also believe that this error falls in the untrapable class, I will find another way to handle the Create record part.

    Thanks guys for your help

    Carlos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •