Results 1 to 7 of 7
  1. #1
    JonathanT is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    118

    Parameter query not working with combo box

    I have a parameter query that I want to get a value from a single combo box on a form. In the combo box I want the values to come from a field in a table. The query returns no results when I run it. If I use a combo box that has a value list the query works fine. It doesn’t work when the combo box gets it’s values from a table. Here is the row source information from the combo box

    SELECT [AllDataTBL].[ID], [AllDataTBL].[PropertyDate] FROM [AllDataTBL] ORDER BY [PropertyDate] DESC; The row source type is 'Table/Query'

    Any help would be appreciated. I'm new to this. Happy to provide more information.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    And the parameter query SQL looks like....??????

    If I use a combo box that has a value list the query works fine
    What are the value list members?

  3. #3
    JonathanT is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    118
    Here is the Query and the Criteria is [Forms]![DisplayDataFrm]![Testing] .

    The value list works. It's when I try to have the combo box get it's values from a table that the query doesn't work. Examples of the Table values are 10/20/17 Denver, 10/20/17 Houston etc. The table field is formatted as short text

    Click image for larger version. 

Name:	Snapshot.JPG 
Views:	15 
Size:	61.6 KB 
ID:	31006

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Unless you're specifying column 2 as the bound column, you are returning the ID value to the PropertyDate field. The combo needs to have 2 columns with the first width being 0" and move the expression to the ID field of the query.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Another option is to change the combo box row source: The "ID" field is not being used, so change from
    Code:
    SELECT [AllDataTBL].[ID], [AllDataTBL].[PropertyDate] FROM [AllDataTBL] ORDER BY [PropertyDate] DESC;
    to
    Code:
    SELECT DISTINCT [AllDataTBL].[PropertyDate] FROM [AllDataTBL] ORDER BY [PropertyDate] DESC;
    ------------------------------------------------------------------------

    I do see other issues:

    - Why are tables "AllDataTBL" and "PropertyDataqry" joined by the "ID" field? Or is "PropertyDataqry" a query? Is "PropertyDataqry" already filtered?

    - "Property" is a reserved word in Access and shouldn't be used as an object name (in this case a field name).
    Also, "Property" is not very descriptive.... "Property" of what?? Color of a house? It is a commercial building/residential home? A location??

    - If field "PropertyDate" values are like "10/20/17 Denver", "10/20/17 Houston", you are violating normalization rules - specifically the First Normal Form (1NF)

    A table is said to be in First Normal Form if:
    1) there is no row or column order
    2) each row (record) is unique
    3) each row by column value (field) contains exactly one value
    4) there are no repeating columns

    So field "PropertyDate" is violating rule #3; you have a date and a city as data in one field. There should be two fields - one for the date and one for the city.



    Just something to consider.......

  6. #6
    JonathanT is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    118
    Stupid mistake on my part. I changed the name of the combo box and forgot to change the name in the criteria of the query

  7. #7
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Sometimes you can't see the forest for the trees...

    Been there, done that (alot)......

    Good luck with your project.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-15-2016, 09:50 AM
  2. Replies: 6
    Last Post: 02-28-2013, 05:38 PM
  3. Parameter Query not working
    By cphelps48 in forum Queries
    Replies: 3
    Last Post: 10-06-2011, 04:42 PM
  4. parameter query not working
    By denny in forum Access
    Replies: 3
    Last Post: 02-20-2011, 01:07 PM
  5. Add combo box to parameter query
    By louisa14 in forum Queries
    Replies: 1
    Last Post: 12-10-2005, 08: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