Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Vlissingen, Netherlands
    Posts
    63
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Refresh record - Access 2007

    After using a combobox to make a selection the corresponding data only shows after pressing F5.
    The combobox is in the form header and the corresponding data is in the form detail.
    Only one table is used.
    Anybody knows how to set this up using VBA?

    Thanks for the reply.
    Joop

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Joop,

    Try: Forms![YourFormNameHere].Refresh in the ComboBox AfterUpdate Event.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    jbw92 (2012-01-03)

  4. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    Quote Originally Posted by jbw92 View Post
    After using a combobox to make a selection the corresponding data only shows after pressing F5.
    The combobox is in the form header and the corresponding data is in the form detail.
    Only one table is used.
    Anybody knows how to set this up using VBA?

    Thanks for the reply.
    Joop
    What is the recordsource for the form? Does it reference the combobox to select a record? If so, then all you need is this in combobox's AfterUpdate event:

    Me.Requery

    Note that there is a difference between Requery and Refresh. Requery reruns the query; Refresh doesn't rerun the requery, it just gets the latest data for each record originally returned.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. The Following User Says Thank You to MarkLiquorman For This Useful Post:

    jbw92 (2012-01-03)

  6. #4
    Star Lounger
    Join Date
    Apr 2002
    Location
    Vlissingen, Netherlands
    Posts
    63
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks gents for the reply.
    I've tried me.refresh in the AfterUpdate event and it did not work. I'll give it another try and try me.requery as well. Will revert.

    Thanks for pointing out the difference between refresh and requery.

    As already mentioned pressing F5 (assume this is refresh in access as well) showed the remaining record info.
    The refresh was not necessary when using Access 2000 for this database.
    Is there a particular reason refresh has to be used when using ACC2007?

    I noticed a refresh and refresh all option in ACC2007. Is this handled differently by code?

    Thanks for the reply.

    Joop

  7. #5
    New Lounger
    Join Date
    Jun 2010
    Location
    Gurnee, IL, USA
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Joop, I use the following statement to update combo boxes and lists:
    <controlName>.Rowsource = <controlName>.Rowsource
    With the various versions of Access I work with, this is the only reliable method I have found to update a combo box or list. This requires a little VBA programming. You need to run the line whenever the event occurs that changes its underlying source data. For example, if I have a list with 2 combos and number 2 needs to get updated after something is selected in 1, I will put the rowsource=rowsource statement into the onClick event of Combo 1, i.e., combo2.rowsource=combo2.rowsource.
    Hope this helps,
    Kirk

  8. #6
    Star Lounger
    Join Date
    Apr 2002
    Location
    Vlissingen, Netherlands
    Posts
    63
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks Kirk,

    Will give it a try
    Joop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •