Results 1 to 11 of 11
  1. #1
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18

    Update query subform

    Hi,
    I have managed to create a tab with a subform displayed as a database.
    The subform is based on a query that picks criteria from a combobox above.
    In the combobox I have 3 people no 1,2,3 i have set a default value of 1.
    Starting the form works nicely and the def value is given to the query.
    Now
    How do I write an action when I change the combovalue to update the subform.


    I managed to run the query but I want it to update the subform below the combo.
    Lets call the subform "todo_pers"
    Maybe I have misstyped the criteria as well , the combo is named "who" and the criteria states [Forms]![who].
    The default value works initially.
    As the combo has columns 1-no , 2-name with display on 2 , do I need to specify wich column to pick.
    Thanks in advance!
    P

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It sounds like you want to requery the subform:

    Forms!MainformName.SubformControlName.Form.Requery

    If the bound column of the combo is the appropriate column, you don't need to specify it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18
    Ok you are propably right but where do I typ it.
    If I put no action and just hit UpdateAll Im fine so maybe just an update all action.
    How do I get an updateall action?
    In this case "Forms!HUVUDFORM.Uppg_per_pers.form.requery" did not make it.
    Thanks again.
    P

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Typically in the after update event of the combo. You can use VBA code or a macro. VBA would go here:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18
    Yes I got that far and managed to Docmd openquery and it would open a new window. But thats not what I want.
    Tried inserting
    Forms!HUVUDFORM.Uppg_per_pers.form.requery
    That did not work.
    In 2010 I have a button for Update all that does the trick but I don't know how to invoke it by VBA.
    P

  6. #6
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18
    Now if I type
    Forms!HUVUDFORM.Uppg_per_pers.requery
    I get error code 2465 runtime error
    But if I type
    Forms!Uppg_per_pers.requery
    I get "cant find form Uppg_per_pers"
    HUVUDFORM is my main form.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18
    Yepp !
    Huvudform has tabs no3 Att gora ( To do in swedish don't know how this will turn out to you with some swedish letters)
    is the one the bottom subform based on the query"HUS Ej klart pr pers" has a combobox on top VEM (who).
    VEM has a default value of 2 and that is used initially by the query.
    If I swap person in VEM I want the subform below to update. In ACCESS 2010 I can change person and hit the update all button and all is dandy, but when I use this from ACC2003 there is no Update button.
    Patrik
    Attached Files Attached Files

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It keeps locking up on me, but does this work for you (in the after update event of the combo):

    Me.Per_pers.Form.Requery

    You want the name of the control, not the name of the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    putte11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    18
    Fantastic, thanks a million !
    That was beyond me. Then again being a total rookie with no ACCESS education what so ever , I´m quite happy with what I have accomplished. These forums are of great help.
    Patrik

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help Patrik!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Update Subform using apend query
    By burrina in forum Forms
    Replies: 13
    Last Post: 11-14-2012, 03:11 PM
  2. Replies: 1
    Last Post: 11-07-2012, 05:31 PM
  3. Replies: 1
    Last Post: 07-20-2012, 09:48 AM
  4. Replies: 3
    Last Post: 03-11-2012, 08:24 PM
  5. Update field in table after update on a subform
    By jpkeller55 in forum Queries
    Replies: 3
    Last Post: 09-30-2010, 08:02 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