Results 1 to 6 of 6
  1. #1
    dwheatley is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    22

    How to add new company in drop down box in a form

    Hi,

    I am trying to make my Form as efficient as possible.

    Using a combo box I have it set up so that when I enter a new company name which is not already on the drop down box, it will save that entry to my table.

    However, when I go to use the form again, I want that new entry to show up on the drop down box as an option.

    I tried selecting the option 'I want the combo box to get the values from another table or query' option, but when this is selected it does not allow me to add a new name to the drop down box in the form if it isn't already available in the table (which kind of renders the point of the form useless).

    Any help?

    Many thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    i have a button next to the drop box [add] which opens that table to add new items.
    docmd.opentable "tCodes"

    but once you add items there, and come back to the form, you must click the REFRESH ALL button on the toolbar to see the added items in the combo.
    this is the simple solution.

    you can always make the add new code a form
    docmd.openform "frmCodes"

    and place a REFRESH ALL button on that form to refresh everything, but why re-invent the wheel?

  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
    Join Date
    Apr 2017
    Posts
    1,679
    When company info is read from separate table, then you have to add new company in separate form, or you have to use some unbound controls on your form to enter at least the new company name, and a button to add new company to companies table, refresh combo's recordsource, and set the new value for combo equal with freshly added one.

    When you have company name saved directly in items table, then you can use a single-column combo to select from existing company names in your items table (YourCombo.Rowsource = SELECT DISTINCT CompanyName FROM ItemsTable ORDER BY CompanyName) and set LimitToList = No for combo (ColumnCount = 1 of-course). Whenever the user doesn't find the company name from drop-down, it can be entered into control. Whenever the user then moves to another record, the record with new company name will be saved, and the new company name will be accessible in combo.

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    If it is saving the new name into the table ok, then at the end of your code requery that combo box and it should now have that new value.

    Me.YourComboboxName.Requery

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Or use the approach suggested in orange's post and don't need to write code. Mind blown!

    I've seen that ListItemsEditForm property but never explored.
    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: 3
    Last Post: 11-06-2016, 12:57 PM
  2. transfer company name from one form to another form
    By peterjb44 in forum Programming
    Replies: 9
    Last Post: 01-21-2014, 04:12 PM
  3. Replies: 1
    Last Post: 10-31-2012, 01:27 PM
  4. Replies: 3
    Last Post: 12-30-2011, 01:20 PM
  5. Replies: 3
    Last Post: 11-29-2011, 07:01 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