Results 1 to 11 of 11

Thread: Crashing Form

  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Crashing Form

    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

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Crashing Form

    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.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Crashing Form

    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?

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Crashing Form

    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? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)
    What Child and Master links do you have set up for each subform?
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Crashing Form

    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

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Crashing Form

    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.
    Charlotte

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Crashing Form

    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?
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Crashing Form

    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!!? <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>The 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.

  9. #9
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Crashing Form

    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?

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Crashing Form

    I've never used the Form wizard to create a form with subforms, so I had no idea what you were talking about. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> 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.
    Charlotte

  11. #11
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Crashing Form

    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

Posting Permissions

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