Automatically saving data in Combo Boxes

  • Thread starter Thread starter NYBronxBombers
  • Start date Start date
N

NYBronxBombers

Guest
How can you make the combo box save previously entered data for future records. In other words, in the form, I want to type in data and then have that data show up in a drop down menu in new records as a choice. If my new data is not one of them then whatever I type in will also be added to the list of choices in the combo box.
 
Bronx,

There have been several posts regarding that. You really only need a
couple of lines of code to do it.

DoCmd.RunSQL "Insert new item into your table ..."
Me.cboMyCombo.Requery

But there is also the "Not in list" message that Access provides. I'll try
to find an example.

Wayne
 
I am very new to this and do not know what I am doing so please make this as painless as possible. Thanks
 
This is a cheesier way to do it but it works.

Is the combo box bases off its own query. If so you can make a new form based off of a query or table that has the entries for the combo box.

go to the combo box on the previous form and do this

Right click on the combo that you want to add a entry into.
Click on the events tab
On dbl Click event click the ... button

add

Code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "<The name of your new form>"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Now when you double click the combo box it will pop up your new form for you to add a new value.



On the close event of your new form put something like

[forms]![<NameOfYourMainForm]![<NameOfYourComboBox].requery


This will requery the data in the combo box to add the new entries.

There are better ways to do this but this is the easiest.
 

Users who are viewing this thread

Back
Top Bottom