Results 1 to 7 of 7
  1. #1
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36

    Unique values for combobox

    I have a table named "Categories". I have a field named "Method" in that table. I would like to display unique values from the said field in a combobox. To test this out, I created a blank form, added the combobox, went into the Query Builder form, set "Unique Values" from the Query properties to Yes. I then ran the query and everything displays just the way I want it. I then save changes to the combobox but when I go to Form view the combobox is empty.



    I checked the row source and true to form it says SELECT DISTINCT Categories.Method FROM Categories...so why then does this only work when I run the query but not for the combobox?

    I must have been playing around with this for hours to no avail. I find that when I follow this process on an existing query instead of a table it works just fine with the combobox - it just doesn't seem to work with a table. Any ideas what I could be doing wrong?

  2. #2
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36
    It seems to have something to do with the subdata sheets. After getting rid of them I notice that it works...not sure why. Talk about trial and error.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I then save changes to the combobox but when I go to Form view the combobox is empty.
    Data is stored in tables. I'm not sure what you expect or mean by saving changes to combobox.
    If you set the row source property of the combo to SELECT DISTINCT Categories.Method FROM Categories and saved the form design, I would expect the form and combobox to be consistent.
    Perhaps there is more to your set up.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,679
    It seems to have something to do with the subdata sheets
    Is OP creating forms as datasheets?

  5. #5
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36
    The asnwer to my question appears to be here, item 2:

    http://access.mvps.org/access/lookupfields.htm

  6. #6
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36
    Quote Originally Posted by orange View Post
    Data is stored in tables. I'm not sure what you expect or mean by saving changes to combobox.
    If you set the row source property of the combo to SELECT DISTINCT Categories.Method FROM Categories and saved the form design, I would expect the form and combobox to be consistent.
    Perhaps there is more to your set up.
    You SELECT the fields, FROM the table generated by the object (WHERE) known as the combobox. That SQL is part of the script saved under the combobox which runs every time you select the combobox (that's how the combobox generates the queries from the table). So when I say "save changes to the combobox" I'm talking about the script, not the data...

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Most developers/responders will advise you to ignore/avoid lookup fields in tables.
    It still isn't clear to me what you are trying to accomplish. Perhaps you could describe your intentions in plain English.
    Since you seem new to database and Access, I recommend that you review some of the articles at the link to Database Planning and Design in my signature.
    You appear to be working with Forms and Controls which are associated with user interface typically. I suggest you focus on describing the "business" that you wish to automate with this proposed database, and work through 1 or 2 of the tutorials from RogersAccessLibrary mentioned in the link above.

    Good luck with your project.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-09-2016, 01:23 PM
  2. Replies: 6
    Last Post: 04-08-2016, 07:32 AM
  3. Replies: 3
    Last Post: 03-02-2016, 06:05 PM
  4. Unique values in combobox list
    By richardm55 in forum Forms
    Replies: 19
    Last Post: 07-10-2015, 12:40 AM
  5. Combobox setting other combobox values problem
    By maxmaggot in forum Programming
    Replies: 8
    Last Post: 06-30-2013, 07:18 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