Results 1 to 6 of 6
  1. #1
    MWMike is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Long Island, NY
    Posts
    18

    Cool Query results in subform

    Hi all,

    I have a form with a combo box whose values I use as the criteria for a query. I also have a command button that runs the query. I want to display the query results in a subform datasheet (see attached picture).

    However, when I click the button, the query runs and opens the results in a separate query datasheet, and doesn't update my subform.



    To run the query when I click the button I used the "command button" wizard and set the action to "run query". I have the subform "source object" set to the query. I am probably missing some code somewhere, but I am still new, and have been sticking to the macros as much as possible.

    Thanks for the help

  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
    Rather than run a query, you want to requery the subform. You can probably use a macro, or in VBA code:

    Me.SubformControlName.Requery
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MWMike is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Long Island, NY
    Posts
    18
    Quote Originally Posted by pbaldy View Post
    Rather than run a query, you want to requery the subform. You can probably use a macro, or in VBA code:

    Me.SubformControlName.Requery
    Hi, thanks for the reply.

    I can't seem to find a macro for that in the options that come up for "action". I have yet to start playing around with the VBA code. Where do I put it? I tried putting it in the _Click() statement for the button but it didn't do anything.

  4. #4
    MWMike is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Long Island, NY
    Posts
    18
    I still have the subform "source object" set to the query I was running before. Without the "run query" action of the button, I don't see how this works

  5. #5
    MWMike is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Long Island, NY
    Posts
    18
    Sorry! should have spent more time playing around with it. It works fine! I guess I had some old buttons that I deleted whose code still showed up in the VBA editor. The names were similar so I put the code in the wrong place.

    Thanks!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Ah good, glad you got it working.
    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. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  2. Replies: 0
    Last Post: 03-31-2010, 07:52 AM
  3. Query not returning all of the results
    By velvettiger in forum Queries
    Replies: 4
    Last Post: 03-11-2010, 06:56 AM
  4. Replies: 4
    Last Post: 01-11-2010, 11:41 PM
  5. Subform results
    By terryvanduzee in forum Forms
    Replies: 1
    Last Post: 10-13-2009, 07:52 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