Results 1 to 2 of 2
  1. #1
    zipmaster07 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    22

    Pass parameters to a query from a form

    I have a query that returns a count of the number of products a customer currently has. The query has a parameter that asks for the customer_id.

    I want to use the query as the control source of a field on a form. I need the form to pass the currently selected customer_id (the one they are looking at) as the query parameter value. How is this done, or is there a better way to do this? The form only looks at a single customer (and therefore customer_id) per page. Query is below:



    PARAMETERS contractor_name Short;
    SELECT COUNT(contractor_leads.contractor_id) as [Actual Leads]
    FROM contractor_leads
    WHERE contractor_leads.contractor_id = contractor_name
    AND contractor_leads.active = TRUE;

    Thanks

  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,518
    The query would look like:

    PARAMETERS Forms!FormName.ControlName Short;
    SELECT COUNT(contractor_leads.contractor_id) as [Actual Leads]
    FROM contractor_leads
    WHERE contractor_leads.contractor_id = Forms!FormName.ControlName
    AND contractor_leads.active = TRUE;
    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: 8
    Last Post: 12-21-2011, 12:50 PM
  2. Pass a Form Filter to a Query
    By kenton.l.sparks@gmail.com in forum Programming
    Replies: 4
    Last Post: 04-01-2011, 11:48 AM
  3. Pass a value from a query to a form
    By cwwaicw311 in forum Forms
    Replies: 22
    Last Post: 03-22-2010, 10:21 AM
  4. Pass command line parameters
    By lanto3000 in forum Access
    Replies: 2
    Last Post: 03-21-2010, 03:53 PM
  5. Pass a Parameter From a form to a Query
    By DDillesha in forum Forms
    Replies: 1
    Last Post: 10-28-2009, 12:49 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