Results 1 to 11 of 11
  1. #1
    LAazsx is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    30

    How to refresh and close a form


    How do i close and refresh a form using VBA?
    Code:
       Forms("Adviser Records").Refresh
    Code:
        DoCmd.Close acForm, "New Adviser"
    These are the codes I'm using. No errors pop up. It just doesn't work. The other parts of the code still work.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    is this behind the actual form?

    and why are you refreshing it before the close? that is irrelevant, because a form saves itself automatically

  3. #3
    LAazsx is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    30
    I have two forms. Form 1 will display the contents of the table (Split Form) while Form 2 is where data for the table is entered. So when Form 2 closes, it will refresh Form 1.

    I also have a Delete button in Form 1. When an entry is deleted, #Deleted is shown in the datasheet part of the form

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by LAazsx View Post
    I have two forms. Form 1 will display the contents of the table (Split Form) while Form 2 is where data for the table is entered. So when Form 2 closes, it will refresh Form 1.

    I also have a Delete button in Form 1. When an entry is deleted, #Deleted is shown in the datasheet part of the form
    first of all, "refresh" is different than 'repaint' and 'requery'. how different, i don't know. I believe refresh will get rid of those delete symbols, but not 100% sure. try them all.

  5. #5
    Join Date
    May 2010
    Posts
    339
    When you close form2, open form1 it will requery form1 for you.
    And the reverse can be done, so they query each other.
    Use the forms close event.


    Code:
    Private Sub Form_Close()
    DoCmd.OpenForm "frmName", acNormal
    End Sub 

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Quote Originally Posted by ajetrumpet View Post
    first of all, "refresh" is different than 'repaint' and 'requery'. how different, i don't know. I believe refresh will get rid of those delete symbols, but not 100% sure. try them all.
    FYI, Refresh does *not* get a new RecordSet so the *deleted* records are still there. It would need to be Requeried to take care of that. Refresh will get any *new* data in existing fields in the current RecordSet. Blaster's suggestion is a good one.

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by RuralGuy View Post
    FYI, Refresh does *not* get a new RecordSet so the *deleted* records are still there. It would need to be Requeried to take care of that. Refresh will get any *new* data in existing fields in the current RecordSet. Blaster's suggestion is a good one.
    You got it sir! Hey Allen, is code always needed to go back to the same record you were on after a requery? doesn't a requery always take you back to rec 1?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Quote Originally Posted by ajetrumpet View Post
    ...is code always needed to go back to the same record you were on after a requery? doesn't a requery always take you back to rec 1?
    The answer here is YES to both questions.

  9. #9
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    just wanted to ask a guru. I've got code for it, but never explored the difference between the 3 methods I don't think.

  10. #10
    LAazsx is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    30
    Thanks guys, Appreciate the help

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You're very welcome.

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

Similar Threads

  1. Refresh Query using Value on Form?
    By AKQTS in forum Programming
    Replies: 3
    Last Post: 10-25-2010, 09:33 AM
  2. update/refresh form
    By SlowPoke in forum Access
    Replies: 3
    Last Post: 09-20-2010, 09:21 AM
  3. refresh a form
    By RedGoneWILD in forum Forms
    Replies: 18
    Last Post: 09-03-2010, 08:31 AM
  4. Close All but One Form
    By Bruce in forum Forms
    Replies: 4
    Last Post: 04-06-2010, 09:31 AM
  5. close form
    By taylorosso in forum Forms
    Replies: 5
    Last Post: 08-25-2009, 12:18 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