Results 1 to 3 of 3
  1. #1
    RedWolf3x is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Posts
    31

    Dynamically selecting Parameter Fields via a Combo Box

    I'll Try to keep this short and sweet.



    I know in SQL you can put

    Where Table1.Field1 = Forms![Form Name]![Combo Box Name]

    How can I make the Combo box Select Which Field to Filter By

    The Combo box has a list of fields from the table

    Where Forms![Form Name]![Combo Box Name] = Some Value

    I'm guessing I'll need to have VBA dynamically create the Query, but I was hoping to avoid having to do that.

    Background.

    I have a table used for scoring phone calls. It has multiple columns based on different categories. Each month there are incentives given out based off who has "Met" a couple of selected categories for the month.

    A query has already been created that pulls the data, however I need to go into the SQL and rewrite which fields are being selected each month. One Month might be Greeting and Gaining Control, the next month might be Closing and Notes. There are 17 categories currently so writing a query for each combination is out of the question.


    Thanks.

    -Red

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I doubt can do without VBA.

    I use dependent comboboxes and VBA code.

    First combobox offers a list of fields. When item selected VBA code sets the RowSource of the second combobox. Then more code builds a critiera string that is applied to form Filter property.

    It's a fairly long and complicated coding.

    If you want to change the WHERE clause of a query object, that requires code referencing QueryDefs collection.
    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
    RedWolf3x is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Posts
    31
    Thanks, That's what I was afraid of. Well off to VBA land.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2012, 08:39 AM
  2. Replies: 2
    Last Post: 09-21-2011, 07:23 AM
  3. Replies: 5
    Last Post: 07-04-2011, 12:53 PM
  4. Replies: 2
    Last Post: 06-01-2011, 09:32 AM
  5. Replies: 1
    Last Post: 08-13-2010, 01:06 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