Results 1 to 6 of 6
  1. #1
    dniezby is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2013
    Posts
    183

    Open form using query that used data from another form

    I created this query in designer today and it is called from another form.

    Code:
    SELECT tblContacts.FirstName, tblContacts.LastName, tblCampaigns.CampaignCode
    FROM (tblCampaigns INNER JOIN tblContacts ON tblCampaigns.ID = tblContacts.Campaign_ID) INNER JOIN tblEmailAddresses ON tblContacts.ID = tblEmailAddresses.Contact_ID
    WHERE (((tblCampaigns.ID)=[Forms].[frmCampaign].[ID]));
    On that form, the user clicks a button, it runs the query where it gets it's criteria from the control named ID on that form.

    It works wonderfully, but I'd like to present it in a more pleasing view.

    What I'd like to know is, how do I create a form using the results of this query. Basically, it needs to run the query then open the query as a form.



    I hope I didn't confuse everyone with the way I worded that.

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    Make that query a named query, say qContactCampaign.
    Highlight it in the Navigation Pane and on the ribbon click Create, then Form. A form will be created with the query as its recordsource.
    For this query to work, frmCampaign must be open.

  3. #3
    dniezby is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by davegri View Post
    Make that query a named query, say qContactCampaign.
    Highlight it in the Navigation Pane and on the ribbon click Create, then Form. A form will be created with the query as its recordsource.
    For this query to work, frmCampaign must be open.
    What do you mean by named query? It is saved by the name qryContactsFromCampaign I looked up name query it doesn't tell me much. Is this something I need to code into an onClick event?

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    A query can either be in SQL form (as you gave) or a named query (the links you click on in the query section)

    Just make sure that SQL query has a name that its saved as something

    then follow davgri's advice

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    What do you mean by named query? It is saved by the name qryContactsFromCampaign
    That's a named query.

  6. #6
    dniezby is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2013
    Posts
    183
    Thanks. Got it working by just creating a button to open the form that was using that query as it's record source. Thanks again for the thought process and ideas.

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

Similar Threads

  1. Replies: 4
    Last Post: 06-02-2016, 09:03 AM
  2. Replies: 3
    Last Post: 03-19-2015, 02:11 PM
  3. Replies: 4
    Last Post: 02-14-2014, 11:09 AM
  4. Open Query From Form Data
    By hockeyman9474 in forum Queries
    Replies: 10
    Last Post: 06-20-2013, 01:38 PM
  5. Replies: 1
    Last Post: 05-03-2012, 02:25 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