Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    37

    Unanswered: Requery a subform?

    Ok guys I have one more question for the collective.

    I have a form that contains 4 multi-select listboxes. These listboxes create a query based on the selections by using some VBA I wrote in their AfterUpdate Event.

    What I would like to do now is add a subform to my current form that will show the data that the query created by the listboxes pulls. I can create the subform and set it in datasheet view and it shows the data.

    The problem comes in when I change a value in the listbox. The query that is set as the RecordSource of the subform changes but the subform itself does not update. I would like this to be a more realtime preview that changes when its underlying query changes. I know the query is changing with each new selection in the listbox but the subform does not reflect this.

    Does anyone know how to make it show the current data. I am assuming it is some form of requery or refresh but I can seem to get it right...

    Thanks,
    Garrett

  2. #2
    Join Date
    Feb 2006
    Posts
    37
    Well guys after doing a little more searching and reading and going down a couple different paths I finally got a solution that works.

    I added the following code to reset the subforms recordsource:

    Code:
    Forms!mainFormName!subFormName.Form.RecordSource = "qryName"
    I tried to generalize that so hopefully it makes sense.

    The thing that caused me a couple of problems was that I was leaving out the .Form after the subFormName. Took me a little searching around the forum before I foudn this but it now works beautifully in the afterUpdate area.

    Thanks,
    Garrett

  3. #3
    Join Date
    Jul 2003
    Posts
    81
    I think you can use a tmp Table to add the data and then to set the recordsource of the form to this Table. If you can't do it, send me your mdb or code to help you.

  4. #4
    Join Date
    Feb 2006
    Posts
    37
    M@sterM!nd,

    You must have misunderstood my last post. I actually found a solution all on my own . The code supplied is what I used. I posted it here in hopes that other might be able to use this as well when needed.

    Thanks for the help offer though!

Posting Permissions

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