Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2003
    Posts
    59

    Unanswered: Subform crashing on requery

    On Access 97, if I use the requery method on a subform that has no records and that has AllowAdditions set to false, Access crashes. If AllowAdditions is true then it's OK. If I manually requery using Shift+F9 it's fine.

    Any ideas how I can get round this? I don't have an error message so I don't know what the problem is. Tried in on Vista and XP and I get the same problem.

    Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    If Me.MySubform.AllowAdditions = False Then ...
    How's about that?
    George
    Home | Blog

  3. #3
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by georgev
    Code:
    If Me.MySubform.AllowAdditions = False Then ...
    How's about that?

    Then... ? I still need to requery it in order to display the fact that there's no records. It's the removal of the last record that causes the crash.

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    What do you mean by "access crashes"? It gives no error message, but just locks up?

    Could you first test using:

    If Me.Mysubform.Recorsetclone.Recordcount=1 Then

    If you test this before you attempt to requery, then
    you'll know that you were on the last record. At that point,
    set AllowAdditions to True, and then requery????
    Inspiration Through Fermentation

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Alternatively, a very dirty method of doing this would be
    Code:
    Me.MySubform.AllowAdditions = True
    Me.MySubform.Requery
    Me.MySubform.AllowAdditions = False
    Remembering to set allow additions = false in any error handling/exit handlers you have in place.

    Please only use this as a very last resort.
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by georgev
    Please only use this as a very last resort.
    Yes, I'd thought of this but it seemed rather messy!

    Quote Originally Posted by RedNeckGeek
    What do you mean by "access crashes"? It gives no error message, but just locks up?
    Yes, that's exactly what I mean. You know, that message that wants to submit it to Microsoft and you say Don't Send?


    Anyway, thanks all but this doesn't really address the problem of what's happening. I think it must be something to do with there being no current record.

  7. #7
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    You're right... if your getting that error, there's something bigger going on.
    I assume you've done a compact and repair?
    Inspiration Through Fermentation

  8. #8
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by RedNeckGeek
    I assume you've done a compact and repair?
    Well I hadn't but I have now.

    Anyway, I've decided to bodge it by making allowadditions true if the recordet is empty and disabling the subform so the users still can't add records. I don't much like it but it's stopped crashing!

    Thanks everyone.

  9. #9
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    This might be worth a read:
    http://www.dbforums.com/archive/inde...t-1252879.html

    Although it looks like AllowAdditions=True is still the ultimate answer
    Inspiration Through Fermentation

  10. #10
    Join Date
    Apr 2003
    Posts
    59
    Yes, that does seem to be the same problem as mine. No solution listed though, short of installing a service pack that doesn't work on Vista ;-)

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If it's worth anything, I found that if I set a subform to popup = Yes, Modal = yes, and then do a me.requery command onLoad or OnOpen of the subform, MSAccess crashes unexpectingly. But there were other factors involved as I tried doing this on a new mdb and couldn't get it to crash. Of course why would you ever need to set a subform to a PopUp and Modal? But once I set these to No and took out the me.requery command in the OnLoad or OnOpen, the crashing stopped. Instead of issuing a requery, I also just set the SourceObject of the subform = "MySubformName".
    Last edited by pkstormy; 08-09-07 at 14:27.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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