Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65

    Access crashing when using bookmark,requery, and conditional formatting

    I have a subform ([TrainingQry3 subform]) that on focus inputs the value into an invisible text box. Then I have this text box linked using master/child to another subform ([TrainingTopics subform]) to filter it. Inside this subform I have a Yes/No box that indicates if I want this topic to not apply to this particular employee. If I check the box Yes, indicating that I don't want this employee to be trained on this topic then I have a conditional format that will gray on the row. I wanted to also have the subform requery so that all the grayed out rows are on the bottom. Also, I have a vba code that requeries the subform and brings me back to the saw record using the bookmark function.

    The problem I'm having is that when I click Yes and the subform requeries and the row becomes grayed out, Access crashes.

    Does anyone know why this is?

    Here is the code with the Bookmark function:



    Private Sub NATopic_AfterUpdate()
    strNABookmark = Forms![Employees Form].[TrainingQry3 Subform].Form.Bookmark
    If Me.Dirty Then Me.Dirty = False
    Forms![Employees Form].[TrainingQry3 Subform].Form.Requery
    Forms![Employees Form].[TrainingQry3 Subform].Form.Bookmark = strNABookmark
    Forms![Employees Form].[TrainingQry3 Subform].Form.Category.SetFocus
    Forms![Employees Form].[TrainingQry3 Subform2].Form.Requery
    End Sub
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Have you step debugged?

    Clicking Yes generates error "Microsoft Access can't find the field '|1' referred to in your expression. Debugger goes to line

    Forms![Employees Form].[TrainingQry3 Subform2].Form.Requery

    I comment the line and code works fine.

    The NATopic AfterUpdate event runs before NATopic Click event. Try BeforeUpdate event instead of Click.

    Variable strNABookmark does not get set.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Hi June7,

    Thank you for responding.

    The reason why that error came up was because I took out the form that the code was reading. I have added the form back in. I realized that the database I attached isn't a true representation of what I want. So I have made some changes and attached an updated version. Training Database (3.17.14) - Test.zip

    I tried making the click event a beforeupdate event but I kept getting errors. Can you elaborate more on how and why I should make the click event a beforeupdate event and how I make sure that the msgbox prompt still comes up?

    What do you mean by "Variable strNABookmark does not get set" ?

    Thanks for your help!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Never mind about the BeforeUpdate suggestion.

    I meant when I step debugged and hovered cursor over strNABookmark, it had no value, it was empty. Now I can't find NATopic control on any form in this version.

    Not getting errors anymore. Clicking the checkbox works.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    The NATopic control has a caption name of "Not Applicable" and is in the TrainingTopics subform on the tab "Training Records"

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Okay, found it. That's the checkbox. It is working for me.

    strNABookmark still shows empty

    I commented all the code in NATopic_AfterUpdate and get the same results.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    I can't even click on a field in the TrainingTopics Subform without this happening.

    Click image for larger version. 

Name:	Pic.jpg 
Views:	8 
Size:	167.6 KB 
ID:	15790

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Very odd. Can't replicate the error and I am running that mdb in 2010.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    I just deleted all the conditional formatting and the error goes away and everything works great. I don't understand why the conditional formatting is causing me problems.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Even odder. Does the subform fail with conditional formatting if opened independently from the navigation pane?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    I works fine when its independent from the navigation pane. I think it has to do with the requering of the queries and then going back to the bookmark location. It seems like Access can't handle it.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Except that it is no longer erroring when I run the code.

    Not sure you really need to requery the form. The records are not filtered out of the RecordSource, just the field value is changed. As I said, get same behavior with or without that code.

    Did you try the conditional formatting without the requery code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    I commented out the NATopic_AfterUpdate and the DateTrained_AfterUpdate codes and it still crashes with the conditional formatting.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I would normally suggest corruption is the villain except that I don't get this issue. Since I can't replicate, can't offer solution.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Thanks for the help anyways June7!

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formatting on an Access 2010 Report
    By ecalvert47462 in forum Reports
    Replies: 1
    Last Post: 02-18-2014, 12:18 PM
  2. Replies: 4
    Last Post: 02-11-2014, 11:12 AM
  3. Replies: 3
    Last Post: 11-04-2013, 07:40 PM
  4. Conditional Formatting in Access
    By Triland in forum Access
    Replies: 29
    Last Post: 01-18-2013, 01:00 PM
  5. Access Conditional formatting
    By mailboy in forum Access
    Replies: 1
    Last Post: 12-17-2011, 01:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums