Results 1 to 3 of 3
  1. #1
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37

    Question Refreshing a Form to display new records that were adding using a button and VBA code

    Hi all,

    I have a button on a form that allows the user to create multiple records with the same information (but incremented keys)

    After the button is clicked, I tried to view the records I have just added on the form, but the form still shows the last record that was physically entered (not the last record that was added from the button click.

    I noticed if I close the form and reopen it, I am able to see the records included the ones recently added from the button click



    Is there a way to refresh the form without needing to close it?

    I tried adding
    Me.Refresh
    to the end of the button click function

    I have also tried adding
    Me.Refresh
    Me.Repaint

    And then I added this
    MsgBox "Finished Adding Records"
    Me.Refresh
    Me.Repaint



    because I thought that maybe adding a message box would make the form lose focus to allow for the refresh to work

    ...but still none of these work :/
    Does anyone have any ideas?

  2. #2
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Use Me.Requery instead.

    Me.Repaint and Me.Refresh only redraw the Form without checking to see if the backend data has been changed.

  3. #3
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Thank you! Me.Requery worked great!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-20-2014, 03:25 PM
  2. Replies: 10
    Last Post: 02-09-2012, 04:42 PM
  3. VBA code for adding records to a table
    By pwalter83 in forum Forms
    Replies: 3
    Last Post: 12-21-2011, 10:52 AM
  4. Adding VB code on a embedded coding for a button
    By cwwaicw311 in forum Programming
    Replies: 1
    Last Post: 02-20-2010, 12:25 PM
  5. Adding Command Button To Form
    By uneek78 in forum Forms
    Replies: 7
    Last Post: 03-27-2009, 07:43 PM

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