Results 1 to 7 of 7
  1. #1
    Bolduque is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    3

    Question Form.Refresh not working (.requery does)

    Using MS Access 2016 together with MSSQL 2012 backend via linked tables.



    I have an issue which suddenly popped up which I seem to be unable to resolve.

    I have a set of linked tables (which can be either tables or views) within the access db.

    For at least one of these linked tables I have a form which has a second linked table as a subdatasheet. All of this works fine.

    What I now want to do is after updating a certain field on the linked subform, I want the parent form to be refreshed but not requeried (as the changes in the subform will not cause new or deleted rows in the parent). This however does not work.

    In my subform's control.afterupdate() event I have placed a:

    me.parent.form.refresh

    I see that this refreshes all the records in the subform correctly (which makes sense as refreshesing the parent form should also refresh the linked subform), however nothing changes in the parent form.

    If I were to say me.parent.form.requery then I lose my spot in the parent form (due to the requery) but the changes are correctly reflected.

    If i put a break on the me.parent.form.refresh and I take a look at the view in the sql database I see that the fields have changed (indicating that this is not a timing issue), it just is not visible in access.

    A few weeks ago when I first designed these forms I am 100% sure that this was working, but somehow this does not function anymore. Does anyone have any ideas?

    If required I can provide more information, thanks in advance for taking a look!

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Depending on what has been changed, using recalc may work
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    Bolduque is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    3
    I'm afraid that a .recalc (or even a refresh followed by a recalc) also does not work. There are no MS Access calculated fields, everything is part of linked tables from MSSQL

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Thought you'd say that.

    In that case. bookmark the current record then requery and finally go to the bookmarked record
    If you don't know how to do that, run a forum or Google search - you'll find loads of examples
    You may wish to turn off screen updating first to stop flickering then turn on again afterwards (Application.Echo False ... then True)
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    Bolduque is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    3
    Yeah that is indeed a solution area, would you (or anyone else) know why this doesn't work though? The refresh is quicker and more responsive than the recalc. I have a feeling that I will be ending up with the requery though I truly am interested in why this does not work, especially as I have seen it work a few weeks ago before my holidays

  6. #6
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    The situation you are describing is something I have experienced as well.
    You could try each of the following workrounds and see if any of them help
    1. Set the focus on the parent form then refresh it.
    2. Move to the previous record in the parent then return to the record you had originally.
    3. Force a save in the parent table after setting the focus : If Me.Dirty Then Me.Dirty =False
    4. Try changing the form recordset type to Dynaset (inconsistent updates)

    Suggest you backup the form and subform first
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    there is an accepted solution here
    https://www.accessforums.net/showthread.php?t=59150

    sorry, just noticed that involved a requery, but the simple idea may work for refresh as well
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. VBA to Refresh/Requery a Form
    By justair07 in forum Programming
    Replies: 13
    Last Post: 01-23-2014, 11:19 AM
  2. Replies: 11
    Last Post: 09-17-2012, 02:23 PM
  3. Requery vs. Refresh
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 03-28-2012, 11:54 AM
  4. Refresh Requery Subform
    By eww in forum Programming
    Replies: 1
    Last Post: 04-05-2011, 09:19 AM
  5. Access novice help with refresh/requery
    By cvacgreg in forum Access
    Replies: 3
    Last Post: 02-04-2011, 08:51 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