Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code won't run except in single step mode (2002, SP 3)

    The following code is the first part of the procedure I am trying to run. It works fine if I select the highlighted line and run it in single step mode. However if I try to run it automatically without being in single step mode. The sum of TotTardies which is called TardyCnt does not calculate. I placed the msgbox line in to test the value of TotTardies. In single step mode it has the appropriate value. When not running in single step mode it is null. Can anyone tell me what I can do to fix this problem?

    Private Sub Infraction_AfterUpdate()
    If Me.Infraction < 4 Then
    Me.TotTardies = 1
    End If

    DoCmd.RunCommand acCmdSaveRecord
    <span style="background-color: #FFFF00; color: #000000; font-weight: bold">Me.TardyCnt.Requery</span hi>
    Me.TDate = Date
    MsgBox "TardyCnt = " & Me.TardyCnt
    If Me.Infraction = 1 And Me.TardyCnt = 1 Then
    Me.TTime = Format(Now(), "hh:nn am/pm")
    Me.Discipline = "Warning"
    Me.DisDate = Date
    Me.DisTime = Format(Now(), "hh:nn am/pm")
    Me.LtrDate = Date
    Me.TotMin = Me.Minutes
    Me.Requery
    DoCmd.OpenReport "rptInfraction1", acViewPreview
    Exit Sub
    End If
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    What happens if you replace Me.TardyCnt.Requery with Me.Recalc ?

  4. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    It still reacted the same way. I'm trying to strip down the database so I can post a copy. It will probably be Monday before I can work on it as I am off work now. Thanks for your assistance so far.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    OK, I'll wait.

  6. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    Attached is a stripped file displaying my problem.
    Attached Files Attached Files
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  7. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    You might also try putting a "DoEvents" just after the first requery (that is, insert a new line of code).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #7
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    It still behaved the same way. If I run the code in single step mode, it behaves properly, otherwise it does not.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  9. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    Try setting the Control Source of TardyCnt to
    <code>
    =DSum("TotTardies", "tblTardyDates", "PermNum=" & Chr(34) & [PermNum] & Chr(34))
    </code>
    This appears to recalculate more quickly than =Sum(...)

  10. #9
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code won't run except in single step mode (2002, SP 3)

    That did the trick. Apparently it worked in single step mode because it had more time to calculate. Now it works properly when it runs the code without being in single step mode. Thanks for taking time to look at the problem.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

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