Results 1 to 9 of 9
  1. #1
    DB88 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    110

    Form Refresh problem

    Hello,

    I have a form bound to a query and a VBA code that changes that query's definition (.QueryDefs). The code includes a form refresh (Me.Refresh) but the records don't update. If I close and then re-open the form then the records update. But this is a user interface so I don't want to do that.

    Am I doing something wroing with .Refresh or will that just not work in this case?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try Requery instead of Refresh
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    DB88 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    110
    That worked!!! Thank you so much, that was the last piece of a Search Interface I've been building for 4 days! It works Happy Dance!!!

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by DB88 View Post
    That worked!!! Thank you so much, that was the last piece of a Search Interface I've been building for 4 days! It works Happy Dance!!!
    You're welcome. Glad to help
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    DB88 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    110
    whoops spoke to soon ( pause happy dance).

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by DB88 View Post
    whoops spoke to soon ( pause happy dance).
    Sorry, I don't understand. Do you still have a problem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    DB88 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    110
    Yes, the form doesn't update. If I close the form and then re-open it then the correct records show. Me. Refresh and Me.Requiry do not change the displayed records

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Me.Requery does work. Please post your code.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    DB88 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    110
    If lngLen1 > 0 Then
    CurrentDb.QueryDefs("SubSearch1").SQL = strQ1
    Else: CurrentDb.QueryDefs("SubSearch1").SQL = "SELECT DISTINCT Variant FROM Variant"
    End If
    If lngLen2 > 0 Then
    CurrentDb.QueryDefs("SubSearch2").SQL = strQ2
    Else: CurrentDb.QueryDefs("SubSearch2").SQL = "SELECT DISTINCT Variant FROM Variant"
    End If
    If lngLen3 > 0 Then
    CurrentDb.QueryDefs("SubSearch3").SQL = strQ3
    Else: CurrentDb.QueryDefs("SubSearch3").SQL = "SELECT DISTINCT Variant FROM Variant"
    End If
    If lngLen4 > 0 Then
    CurrentDb.QueryDefs("SubSearch4").SQL = strQ4
    Else: CurrentDb.QueryDefs("SubSearch4").SQL = "SELECT DISTINCT Variant FROM Variant"
    End If
    CurrentDb.QueryDefs("CombineSearch").SQL = "SELECT SubSearch1.Variant, SubSearch2.Variant, SubSearch3.Variant, SubSearch4.Variant FROM SubSearch4 INNER JOIN (SubSearch3 INNER JOIN (SubSearch2 INNER JOIN SubSearch1 ON SubSearch2.Variant = SubSearch1.Variant) ON SubSearch3.Variant = SubSearch1.Variant) ON SubSearch4.Variant = SubSearch1.Variant"
    Me.Requery

    This is just the portion of the code that sets the Queries and then does a refresh. I figured you didn't need to rest where I set up the strings.

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

Similar Threads

  1. question| refresh form
    By mikichi in forum Access
    Replies: 2
    Last Post: 12-03-2013, 12:54 PM
  2. Replies: 1
    Last Post: 01-24-2012, 03:47 PM
  3. Access 2010 Refresh VS Refresh ALL
    By Snwboarder1982 in forum Access
    Replies: 1
    Last Post: 09-09-2011, 04:07 PM
  4. Refresh Form
    By tpcervelo in forum Forms
    Replies: 7
    Last Post: 02-07-2011, 08:03 AM
  5. refresh a form
    By RedGoneWILD in forum Forms
    Replies: 18
    Last Post: 09-03-2010, 08:31 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