Results 1 to 2 of 2
  1. #1
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118

    Requery, Refresh, RePaint, Recalc or Save

    I have a form with a button that runs some VBA code to run an append query that adds some of the detail in the record just added to a table task list. The issue is that it looks like the record has not yet been written when the code runs. E.g. if I manually view the append query before clicking the button (No Results) but if I click off the record then back on to it, then manually view the append query (the query shows the expected results). Therefore I have come to the conclusion that I need to add a line to the code that saves the record first, however I have tried several options and got totally confused with the difference between:
    DoCmd.Refresh
    Me.Refresh
    Repaint
    Recalc
    Save
    Requery



    What should I use to save the record before running the append query please?

    My Code:
    Code:
    DoCmd.SetWarnings False   
        Me.Recalc
        DoCmd.RefreshRecord
        'DoCmd.Requery
        DoCmd.OpenQuery "Qry_Apend_TimeCredit_Task"
        MsgBox "Your request for time owed has been sent to your manager. Your statement will be updated when approved."
    Any help appreciated

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    A lot of people use the Dirty property
    https://stackoverflow.com/questions/...ot-save-record

    That link also includes the SaveRecord command.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Suppress "Requery" and/or "Repaint" when running function
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 12-08-2017, 12:04 AM
  2. VBA to Refresh/Requery a Form
    By justair07 in forum Programming
    Replies: 13
    Last Post: 01-23-2014, 11:19 AM
  3. Repaint or Refresh a form
    By crowegreg in forum Forms
    Replies: 1
    Last Post: 08-20-2013, 03:11 PM
  4. Requery vs. Refresh
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 03-28-2012, 11:54 AM
  5. Refresh Requery Subform
    By eww in forum Programming
    Replies: 1
    Last Post: 04-05-2011, 09:19 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