Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    St Albans, Hertfordshire, England
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access is running too quickly...! (2000 SR1)

    I know it's hard to believe but this is what is happening:

    Main Form is called Digest_Master - contains subform control subInv_Mstr
    2nd Form is called Invoice_Master1

    The on_Click event of btnSave on Invoice_Master1 is set as follows:

    Private Sub btnSave_Click()
    On Error GoTo Err_btnSave_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 'SAVE RECORD
    Forms!Digest_Master!subInv_Mstr.Requery 'REFRESH DATA ON SUBFORM
    DoCmd.Close 'CLOSE Invoice_Master1
    Check_Values 'RUN FUNCTION Check_Values

    Exit_btnSave_Click:
    Exit Sub

    Err_btnSave_Click:
    MsgBox Err.Description
    Resume Exit_btnSave_Click

    End Sub

    Function Check_Values is as follows:

    Function Check_Values()
    If Forms!Digest_Master!Cost = Forms!Digest_Master!txtInvToDate Then 'COST is bound field, txtInvToDate is calculated
    Forms!Digest_Master.Locked.Value = True 'Set checkbox Locked to true
    MsgBox "Record should be flagged as LOCKED", vbOKOnly, "DEBUG MODE" 'Debug msgbox
    Lock_Controls 'Public Function to Lock all data controls on Digest_Master
    Forms!Digest_Master.Repaint 'Repaint Digest_Master
    End If

    End Function

    When I step through the code in break mode, the process works correctly, however, when I run the code in true runtime (i.e. no breaks), it fails to call Check_Values.

    The only thing I can think of, is that it is still closing the Invoice_Master1 form, thereby missing the call to the external public function.

    How can I slow the code down? <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  2. #2
    Lounger
    Join Date
    Mar 2002
    Location
    St Albans, Hertfordshire, England
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access is running too quickly...! (2000 SR1)

    <img src=/S/fanfare.gif border=0 alt=fanfare width=31 height=23>
    Okay, I've got it now (I hope)!

    I've changed check_Values to return a boolean value, and edited btnSave_Click() so it reads:
    ...
    Do Until Check_Values = True
    DoEvents
    Loop
    ...

    This ensures that the code is repeatedly called until it hooks up correctly - possibly noit the best way, but it keeps my fingers on the keyboard ( <img src=/S/compute.gif border=0 alt=compute width=40 height=20>), instead of scratching my head ( <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>)!

    Thanks folks

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Access is running too quickly...! (2000 SR1)

    Why not switch the 2 lines of code, like this:

    Check_Values 'RUN FUNCTION Check_Values
    DoCmd.Close 'CLOSE Invoice_Master1
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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