Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2005
    Location
    Kendal
    Posts
    10

    Question Unanswered: Refreshing form data from a sub form

    Hi there,

    I have a sub form which populates data in a look up table (opened using the ‘Not in list’ event of a combo box on the main parent form). I can refresh the sub form to save the new data but would like to refresh the parent form so that the new data appears in the combo box. Ideally I would like to do this with one click from the sub form. I can’t get the correct code to reference the parent form. Can anyone help?

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Called from subform:

    Forms![My Form Name Here]!MyCombobox.Requery

    Assuming of course that the combo is based on a query and not a table ... You'd have to reload the table and then requery the combo ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Jul 2005
    Location
    Kendal
    Posts
    10
    Thanks for that. That’s basically what I was trying but the combo box is based on a table rather than a query. Is there a non clunky way to reload the table first and display the same record or is it easier just to base the combo box on a query?

    Cheers

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    whether the combo is based on a query or a table is immaterial. effectively to the combobox a table and query are the same thing (a data source presented in some order). The query allows you to join tables or use some esoteric order, or it allows you to reformat the source data - but intrinsically its the same beastie.

    if I'm reading your question right, you have added a new value which 'should' reappear in the combo box on the parent form. if thatsd the case ensuring the new value is written to the backing table for the combo then a requery will pull up that value.

    if you want to make sure that optionj is the value in the combo then refresh / requery the combo and set the value to the required item

    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jul 2005
    Location
    Kendal
    Posts
    10
    Thanks folks, sorted now. I think I was referencing the parent form wrongly when calling it from the subform.

    Just another ‘thick’ question, is there any advantage to using:
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acmenu ver70
    over a simple requery statement?

    Thanks for the help, much appreciated.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    depends on what you are trying to do,
    what you are used to
    and what you expect those following in your footsteps to do.

    Technically I'd guess you vb macro is probably doiung the same thing as as a simple combobox.requery, but I don't know.

    personally I'd use vb/vba over a macro any day, but then thats my background, and my experience, for others docmd may be appropriate. I think its likely that .requery will be more sustainable / supportable over time and different versions of office products.

    effectively there is no simple answer. I'd guess most people contributing to this forum will go down the route of a requery, most newbies wil be happier with the docmd.

    essentially yer pays yer money, yer takes your choice....
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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