Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Requery Of SubForm Based On A Query (Access 2000)

    I have a form containing a sub-from, the sub-form having as its source a query that picks up criteria from the main form.

    I am having difficulty finding the right macro command to get the sub-form to requery its query. For example, if I jump to second form and do something that would change the results of the query in question, I want to see that change when I go back to the first form.

    The standard Requery macro command just doesn't seem to work with sub-forms, or fields within sub-forms.

  2. #2
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Requery Of SubForm Based On A Query (Access 2000)

    Hi

    Can you not set the LinkChild, LinkMaster properties of the subform to the primary keyfield of the main form ?

    Failing that can you set an event for the main form
    maybe onCurrent
    to requery the subform
    e.g
    sub frmMain_OnCurrent
    forms!frmmainForm!frmSubForm.requery
    end sub

    Hope this helps
    Cheers
    Geof

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Requery Of SubForm Based On A Query (Access 2000)

    It sounds like you're using an unbound subform and keeping it in sync the hard way. As has already been suggested, the Master and Child links would be the simplest way to keep them in sync and wouldn't require any requerying. However, in case you *do* need to requery, there are methods to do so.

    Are you requerying it from the parent form, from another subform or from another form altogether?

    If you want to requery it from the parent form, use this syntax: Me!SubformControl.requery. Subformcontrol represents the name of the subform control on your parent form.

    If you want to requery it from another subform on the same form, the syntax is: Parent!SubformControl.requery.

    If you want to requery it from another form altogether, the syntax is Forms!Mainform!SubformControl.requery, where MainForm is the name of the parent form.

    If you're looking for the proper event to use, it depends on what you're doing. Usually, the AfterUpdate event of the form or subform would be my choice.
    Charlotte

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Requery Of SubForm Based On A Query (Access 2000)

    It sounds like you're using an unbound subform and keeping it in sync the hard way. As has already been suggested, the Master and Child links would be the simplest way to keep them in sync and wouldn't require any requerying.

    However, in case you do need to requery, there are methods to do so, but you'll probably need to do it from code. You'll need a SelectObject action first to make your subform's parent the activeobject then a Requery action, and the Control Name should be the name of the subform control. Then you'll have to figure out what event on which form to use to call the macro.

    Are you requerying it from the parent form, from another subform or from another form altogether?

    If you're looking for the proper event to use, it depends on what you're doing. Usually, the AfterUpdate event of the form or subform would be my choice.
    Charlotte

Posting Permissions

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