Results 1 to 2 of 2
  1. #1
    steve1040 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    1

    Listbox value to query parameter

    Hi All,
    Please forgive me I'm new to Access VBA
    I'm attempting to make changes to an access database.



    Currently I have a query that prompts for 3 values
    Entity
    Unit
    WorkerType

    I've created a form that allows the user to select each (Entity, Unit, WorkerType).

    How do I pass the values from the 3 listbox to the query here is the query

    Code:
     
    PARAMETERS [Entity Name] Text ( 255 ), [Unit] Text ( 255 ), [Worker Type] Text ( 255 );
    TRANSFORM Max(WorkertypeOnUnitISO.Expr1002) AS MaxOfExpr1002
    SELECT WorkertypeOnUnitISO.fldEntity, WorkertypeOnUnitISO.WorkerType, WorkertypeOnUnitISO.fldUnit, Max(WorkertypeOnUnitISO.Expr1002) AS [Total Of Expr1002]
    FROM WorkertypeOnUnitISO
    WHERE (((WorkertypeOnUnitISO.fldUnit)=[Unit]) And ((WorkertypeOnUnitISO.fldEntity)=[Entity Name]) And ((WorkertypeOnUnitISO.WorkerType)=[Worker Type]))
    GROUP BY WorkertypeOnUnitISO.fldEntity, WorkertypeOnUnitISO.WorkerType, WorkertypeOnUnitISO.fldUnit
    PIVOT WorkertypeOnUnitISO.Quarter In ("1st Qtr","2nd Qtr","3rd Qtr","4th Qtr");
    Thanks
    Steve

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You are asking the user to enter the values twice. Instead, refer to the values on the form in the query:
    WorkertypeOnUnitISO.fldUnit=Forms!formname!textbox nameforUnit
    etc

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

Similar Threads

  1. Replies: 13
    Last Post: 01-10-2012, 09:56 AM
  2. Display RESULTS of Query into LISTBOX?
    By taimysho0 in forum Programming
    Replies: 6
    Last Post: 11-22-2011, 10:05 PM
  3. Parameter Query?
    By luckysarea in forum Queries
    Replies: 3
    Last Post: 04-22-2011, 12:57 PM
  4. Replies: 29
    Last Post: 02-13-2011, 01:21 AM
  5. Query criteria retrieved from a Form's listbox
    By blacksaibot in forum Programming
    Replies: 1
    Last Post: 01-29-2010, 10:38 AM

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