Results 1 to 6 of 6
  1. #1
    Need_Help is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    7

    How to open a query in a form

    Hi all,



    I have a form that involves a number of text boxes that users may enter text into. Then a button allows them to search by certain fields and the query displays the results in a table format. However, my database involves embedded images and I want users to be able to view them after submitting the query. How can I direct my query to display the results in another form?

    Thanks a lot in advance

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    One way is to set up the second form's RecordSource to refer to the controls of the first form in the Criteria row.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Need_Help is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    7
    OK thanks, that seemed like the first step. I changed the Record Source so that it references a query; I cannot get it to reference another form. The 2nd form will display the results of the query based on what was entered into the corresponding text boxes, but will only appear if you manually open it. I would like for it to come up automatically.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    Don't understand, your statements 'cannot get it to reference another form' and '2nd form will display the results of the query based on what was entered into the corresponding text boxes' appear contradictory.

    Need code to open the 2nd form. Use a command button Click event.
    DoCmd.OpenForm "formname"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Need_Help is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    7
    Thanks! That piece of code worked, combined with adding the query to the form's record source. Excellent.

    What my statements earlier had meant that the main form wasn't opening the display form. By opening the display form, I could view the results of a query because the query itself included the entries from the main form. But I would have to keep switching between forms, something I don't want my users to be doing.

    Now one last question that could save some work or at least my navigation pane from getting too cluttered. Can I make this 2nd form open up the results of any query, where the buttons on the main form decide what query is getting used? Or do I have to create a form for each query?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    What is different about these other queries? Different table source with different fields then yes need a different form. Or are these queries all identical except for filter criteria? Then one form bound to unfiltered query. Send filter criteria to the form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Open form based on query information
    By MFS in forum Programming
    Replies: 3
    Last Post: 06-11-2011, 12:44 PM
  2. Use query result to open form.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-12-2011, 11:18 PM
  3. open form if no records in query
    By MiaAccess in forum Forms
    Replies: 1
    Last Post: 03-05-2011, 12:11 PM
  4. Replies: 29
    Last Post: 02-13-2011, 01:21 AM
  5. Open a form using a query that references a combo
    By accessbobp646 in forum Access
    Replies: 1
    Last Post: 02-22-2009, 09:50 AM

Tags for this Thread

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