• Crashing Form

    Author
    Topic
    #362551

    This is somewhat of a continuation of an earlier post that was partially fixed by re-writing a module. But a problem still persists. A form with two subforms, one a sub of the other, and a combo box set up to search for a customer, consistently crashes on the second or third search. It will always do the first search just fine, and if I close the form and reopen, it will do another search without problem. There are no null link fields. It seems to go into a calculation loop but I think it is query related. The form is based on a table, the two subforms are based on queries. Dr. Watson recorded the following:

    Win32 Kernel core component attempted to write to memory that does not exist or is read-only. It may be using an uninitialized variable, or it may be attempting to access memory after having freed it.

    Module Name: KERNEL32.DLL
    Description: Win32 Kernel core component
    Version: 4.10.2222
    Product: Microsoft® Windows® Operating System
    Manufacturer: Microsoft Corporation

    Application Name: Msaccess.exe
    Description: Microsoft Access for Windows
    Version: 9.0.3822
    Product: Microsoft

    Viewing 0 reply threads
    Author
    Replies
    • #550836

      I’m not sure what you’re trying to do here but yes I believe the code is the problem. First of all, which subform is this current event being fired from and which subform are you trying to requery? The subform or the sub subform? It looks to me like it’s probably in the sub subform and trying to requery the subform (parent of the sub subform), and if that’s the case, then change it to this:

      Me.Parent.Requery

      The subform is the parent object of the Sub Subform, so that syntax will work to requery the subform from its child subform. However, you need to take the whole thing out of the Current event because it triggers itself over and over and the whole thing recurses to the point where it crashes.

      When do you need to requery the other subform and why? If you are doing a search for a record and if these subforms are actually linked using the Master and Child links, you wouldn’t ordinarily have to requery anything.

      • #550888

        This current event is being fired from the subform (subform1). I’m trying to requery the subsubform(subform2). Imagine the typical example of a customer (table) with several orders (subform1) and the items in each order(subform2). Without the query, I can click an order but the items do not change. Its basically the same code as in the Northwinds database example provided by Microsoft as samples. But I can see what you mean about it being in the on current event causing problems. If this is the case, I think Microsoft goofed because the wizard places it there too. How can I link the two subforms without a requery code and have the order details refreshed whenever I click a different order? or what code would you use?

        • #550899

          Hi,
          When you talk about the subsubform, do you mean that subform2 is a subform on subform1 or is this identical to the Customer Orders form in Northwind, where the two subforms are both subforms of the main form, not subform and subsubform? (if that makes sense? grin)
          What Child and Master links do you have set up for each subform?

          • #551064

            Both subforms are on the main form (as in Northwind). Subform1 is linked to the main form, subform2 is linked to subform1.
            Subform1: Child=CustomerID, Master=CustomerID
            Subform2:Child=OrderID, Master=[Ordersubform].form!orderid

            • #551122

              I can’t see anything inherently wrong with that code – it is after all pretty much identical to the Northwind code. Is it possible to attach a stripped-down version of your database? If not, can you post the SQL for the queries your subforms are based on? Also, have you tried importing everything to a new blank database in case it’s a corruption issue?

            • #551308

              The setup and form are indeed identical to the “Customers orders” in the Northwind database. There too, you will notice the “On current” event, but it doesn’t crash. When I removed the same event from my form, and placed it in the “on click event”, no more crashes. But now the user would have to click the “select record”. And I’m curious WHY!!? hairoutThe only difference that I can see is that I have four combo boxes setup as searches (find by last name, find by phone, etc). Could this cause query problems?

              I tried to attach a stripped down version but is 112 Kb at max compression. Will try importing everything into new database and if still a problem post sql.

        • #551073

          You lost me totally. Which wizard places code to requery a subform in the current event and the current event of which form/subform? i’ve never seen a wizard put code in the Current event.

          • #551316

            For Charlotte: If you use the form wizard to construct a form with two subforms, such as the “Customers Orders” form in the Northwind database, the wizard will insert a “Current” event in the first subform which requeries the second subform. I apologize for not being able to put up a sample, but if you look at the Northwind database (courtesy of Microsoft), its structure is identical. Except that my database has a couple thousand records. Could this influence the query?

            • #551326

              I’ve never used the Form wizard to create a form with subforms, so I had no idea what you were talking about. shrug I don’t normally use wizards unless I’m just experimenting and don’t require a well-built form. A couple of thousand records is still quite a small database.

            • #551331

              Small perhaps, but more than the 91 that Northwind has. Is it this size that could be causing the continual crashes in my database while not in the Northwind? I am curious as to what code others would have written in place of:

              Private Sub Form_Current()
              Dim ParentDocName As String

              On Error Resume Next
              ParentDocName = Me.Parent.Name

              If Err 0 Then
              GoTo Form_Current_Exit
              Else
              On Error GoTo Form_Current_Err
              Me.Parent![subform2].Requery
              End If

              Form_Current_Exit:
              Exit Sub

              Form_Current_Err:
              MsgBox Error$
              Resume Form_Current_Exit
              End Sub

    Viewing 0 reply threads
    Reply To: Crashing Form

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

    Your information: