• MDI Form Error on Close (VB6)

    Author
    Topic
    #406770

    I’ve been plagued with this intermittent problem that is now happening pretty consistently. I have a main form that has a search button on it. When the end user selects the search feature and the criteria returns multiple records I launch another form (vbModal) displaying the return in a ListView grid. I have a select button, a cancel button, and code in the double click event. In the double click and select button events it takes the index number of the record, loads it into a global variable to pass the value back to the calling form, then closes the form using the command Unload Me. Clicking on the Cancel button simply executes the Unload Me.

    The error I’m getting is “Invalid procedure call or argument” and it occurs when I attempt to select the record. It is a generic error not handled by any error handler in the form or calling form. This is unusual to me because I went through every line of code and made sure everything was trapped by an error handler (also verified that I’m releasing all my object variables while I was at it).

    Extremely frustrating that it works fine in my development environment but will error every time for every record when running on the server. This is in a citrix session but that shouldn’t make a difference. The server was recently built and has all the updates on it with the latest MDAC. I had to use a series of message boxes to identify exactly where the point of failure was and keep compiling the code to the server. I found it was occuring in the Unload Me statement itself. I’ve tried Unload frmDupes (the name of the form), I’ve tried hiding the form…no matter what I try I still get this error and I can’t even figure out where it is being spawned from.

    I am completely out of ideas and would appreciate any suggestions.

    Viewing 1 reply thread
    Author
    Replies
    • #845908

      Try Me.Hide and then Unload the hidden form from the code in your other form?

      • #845979

        I get the same error. It does execute the next line of code (a message box telling me where it is at) but the error appears to kill the project before control is passed back to the calling form.

        • #846012

          So you have, more or less:

            Me.Hide
            MsgBox “Me Hidden”
            End Sub
            [/list]*Boom* error message.

            It sounds as though perhaps the problem is in the form that is regaining control. What is the next thing that VB is supposed to do?

          • #846028

            Yes, well, close enough. I also have a message box following the form.show in the calling form that is triggered after that generic error is raised.

          • #846029

            Yes, well, close enough. I also have a message box following the form.show in the calling form that is triggered after that generic error is raised.

          • #846427

            Okay, did some painstaking troubleshooting I want to share with you that yielded some interesting results.

            The way this application works is that you have a main form that you are querying records bases on a criteria entered by the user. When there are multiple returns I show frmDupes in a modal state that contains a listview control showing all of the possible records. The user has a variety of ways to select which record they need. When a record is selected the value of the record is stored in a global string variable called gsMRN. The form is subsequently closed and the calling form, frmMain, then validates and processes the value of gsMRN. Works perfectly in my IDE envoriment. When compiled to the server it returns an unhandled error from somewhere…which I’ve already described.

            In the frmMain, if I were to do something like “msgbox gsMRN” – I would first get the unhandled error, then I get the message box with the appropriate value listed from the global var, then the application ends after clicking on the OK button of the message box.

            Have you seen anything like this? I’ve even tried doing this with different data types, including Variant.

            • #846469

              I’ve never seen anything like this. But we can discuss a multipage control featuring randomly accessible listboxes using ADO to read an XML file some time. laugh

              I wonder whether there is something that VB is doing in the background, destroying some object or closing some connection, that it is doing after something else is closed or destroyed that is causing this problem. Think about how the server environment might respond differently than the development environment in terms of what’s slower (data access always is a possible culprit). Perhaps there’s something you can do in the submit handling code in your modal form, before hiding it, to take care of “something” that otherwise happens too slowly?

            • #846648

              I’ve continued troubleshooting since we talked last. I’ve found that wherever there is a msgbox command, it will raise that error, show the message box, then kill the application. I’ve ran several tests at numerous points in the code and happens 100% of the time. I think I can eliminate the Citrix seemless session as a factor because when I remote into the server and run it directly, I get the same thing.

            • #846649

              I’ve continued troubleshooting since we talked last. I’ve found that wherever there is a msgbox command, it will raise that error, show the message box, then kill the application. I’ve ran several tests at numerous points in the code and happens 100% of the time. I think I can eliminate the Citrix seemless session as a factor because when I remote into the server and run it directly, I get the same thing.

            • #846470

              I’ve never seen anything like this. But we can discuss a multipage control featuring randomly accessible listboxes using ADO to read an XML file some time. laugh

              I wonder whether there is something that VB is doing in the background, destroying some object or closing some connection, that it is doing after something else is closed or destroyed that is causing this problem. Think about how the server environment might respond differently than the development environment in terms of what’s slower (data access always is a possible culprit). Perhaps there’s something you can do in the submit handling code in your modal form, before hiding it, to take care of “something” that otherwise happens too slowly?

          • #846428

            Okay, did some painstaking troubleshooting I want to share with you that yielded some interesting results.

            The way this application works is that you have a main form that you are querying records bases on a criteria entered by the user. When there are multiple returns I show frmDupes in a modal state that contains a listview control showing all of the possible records. The user has a variety of ways to select which record they need. When a record is selected the value of the record is stored in a global string variable called gsMRN. The form is subsequently closed and the calling form, frmMain, then validates and processes the value of gsMRN. Works perfectly in my IDE envoriment. When compiled to the server it returns an unhandled error from somewhere…which I’ve already described.

            In the frmMain, if I were to do something like “msgbox gsMRN” – I would first get the unhandled error, then I get the message box with the appropriate value listed from the global var, then the application ends after clicking on the OK button of the message box.

            Have you seen anything like this? I’ve even tried doing this with different data types, including Variant.

        • #846013

          So you have, more or less:

            Me.Hide
            MsgBox “Me Hidden”
            End Sub
            [/list]*Boom* error message.

            It sounds as though perhaps the problem is in the form that is regaining control. What is the next thing that VB is supposed to do?

      • #845980

        I get the same error. It does execute the next line of code (a message box telling me where it is at) but the error appears to kill the project before control is passed back to the calling form.

    • #845909

      Try Me.Hide and then Unload the hidden form from the code in your other form?

    Viewing 1 reply thread
    Reply To: MDI Form Error on Close (VB6)

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

    Your information: