Results 1 to 9 of 9
  1. #1
    thulot is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jan 2018
    Posts
    12

    How do I Modify a Combo List Box in a Many-to-Many Relational DB?

    Hello, everyone, I am using Access 2013 and need a little bit of help. (I’m not really well-versed in databases.)


    I’m not 100% sure how to edit and modify a combo box. I’ve figured out how to create a query that displays the list, but I’m unable to delete anything in it, add anything to it, or modify it. I’m obviously doing something wrong.


    I’ve attached a copy of the database in .zip format to this message. The combo box in question is named DVD Prefix. Here’s a screen shot of the box.


    After reading some documentation and watching a couple of You Tube videos, I am a little more confused. I’m sure this is something easy, but I’m not grasping it. Can anyone please point me in the right direction? Thank you. J. Danniel

    Click image for larger version. 

Name:	accesslist.jpg 
Views:	20 
Size:	126.0 KB 
ID:	32979
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    If you want to modify the combobox list, you must edit the source, then requery the combobox. If you want to add items to the list 'on-the-fly' during data entry, use its NotInList event. Review http://www.fontstuff.com/access/acctut20.htm

    Instead of building a query for each color, suggest you build one query and use a dynamic parameter to filter records. Or code that applies filter to report when it opens. Review http://www.fontstuff.com/access/acctut20.htm
    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
    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,722

  4. #4
    thulot is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jan 2018
    Posts
    12
    Quote Originally Posted by June7 View Post
    If you want to modify the combobox list, you must edit the source, then requery the combobox. If you want to add items to the list 'on-the-fly' during data entry, use its NotInList event. Review http://www.fontstuff.com/access/acctut20.htm

    Instead of building a query for each color, suggest you build one query and use a dynamic parameter to filter records. Or code that applies filter to report when it opens. Review http://www.fontstuff.com/access/acctut20.htm

    Thanks for replying. I'm going to tweak the color queries. I don't need all of them. But I'm not 100% sure what you mean by editing the source. Can you elaborate further, please? I can add items on the fly, but I still haven't figured out how to edit the list. Thank you.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    I had assumed you have a table of DVDPrefix descriptions. But I now see you are pulling these values from tblMovies with a DISTINCT query.

    What do you mean by 'edit the list'? What items do you not want to show in the list?
    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.

  6. #6
    thulot is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jan 2018
    Posts
    12
    Quote Originally Posted by June7 View Post
    I had assumed you have a table of DVDPrefix descriptions. But I now see you are pulling these values from tblMovies with a DISTINCT query.

    What do you mean by 'edit the list'? What items do you not want to show in the list?
    I'm not really well-versed in database design. I managed to design this database with a LOT...a LOT...of help. I'd never be able to do it by myself.

    Let me try to explain what I want to do. The list has the word NONE in it, and I want to delete that. I do not know how. I know how to add items on the fly, but I want to modify some of the items in the list.

    For example, instead of having the letter B in the list, I want the word BLUE. Or instead of R, I want the word RED.

    That is what I mean by editing the list. I want to delete something, I want to alter a few things. I hope that makes sense. I have no idea what a "DISTINCT" query is.

    If it is easier to have a table of DVDPrefix descriptions, then I'd be interested in changing things. However, would that be too late? Would I have to re-enter a LOT of data into the database if I do that?

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Your distinct query is qryDVDColor.
    Code:
    SELECT DISTINCT tblMovies.DVDColor
    FROM tblMovies
    ORDER BY tblMovies.[DVDColor];
    The keyword Distinct means that your query will pull only one instance of each value in tblMovies.DVDColor.

    You can create a lookup table with only the values you want. You would then change the rowsource of the combobox to something like
    Code:
    Select DVDColor from tblDvdColors orderby DVDColor

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,404
    thulot-Movie Database 2018 davegri-v01.zip
    Take a look at the attachment.
    You were storing the actual text prefix in tblMovies.
    I added a new table, tblDVDPrefix with the prefixes and a primary key.
    tblMovies is now storing a foreign key pointing into tblPrefixes (I changed the dvdprefix field from short text to number in tblMovies).
    On form Movies, if you right click on the dvd Prefix field you get an option 'Edit list items'. It will pop up a simple modal form to edit the codes in tblDVDPrefix.
    With this setup, if you edit the combobox, say, to change W to White, EVERY record that was formerly W will now show WHITE. If you want to see
    both W and WHITE, you will have to add a new code to do that (now showing both W and WHITE in the dropdown).

    The query that was formerly the rowsource for combobox dvdprefix is no longer needed. tblDVDPrefix replaces it.

    The new code module, basConversion, contains the code to convert the tblMovies dvdPrefix field from the alpha codes to the numeric key codes in tblDVDPrefix.
    It can be deleted. I Left it there as an example.
    Last edited by davegri; 03-10-2018 at 04:48 PM. Reason: more

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    The combobox RowSource is an SQL statement that references query object named qryDVDPrefix. Look at the SQL statement for that query and you will see the DISTINCT keyword.

    Could have just made the combobox RowSource statement the statement from that query object instead of building a query from a query.

    Since the combobox RowSource list is based on data in tblMovies, you would have to fix the data in the table. However, as the combobox is currently set up, users can enter anything they want and the entries become items in the list. This is an aid for users to select items that have been previously entered but doesn't restrict their input.

    If you want to restrict what is allowed for input then do what moke123 suggests (and what I had assumed you already had), build a lookup table. Use that as the source for the combobox RowSource.

    You will then have to edit the data in existing tblMovies records to comply with the restricted list.

    And now I see davegri has provided you a modified db to incorporate this suggestion. Enjoy!
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2018, 11:00 PM
  2. Replies: 3
    Last Post: 05-24-2017, 01:26 PM
  3. Replies: 7
    Last Post: 03-07-2017, 03:01 PM
  4. Replies: 4
    Last Post: 10-21-2013, 11:06 AM
  5. Replies: 2
    Last Post: 07-11-2011, 04:51 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