Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box (Value List)

Status
Not open for further replies.

Sullaway

Technical User
Sep 27, 2000
50
US
I would like to give users the capability of adding NewData to a combo box (value list). I found code that allows you to add for that once incident. If you go to a new record or close and come back the value is no longer on the list. What I'm looking for is code that will add the NewData to the list itself so if you change records or start a new record the NewData that was added by a user several records ago now shows up on the list.

Any help would be appreciated

P.S. The code I'm referring to that I found is in FAQ.
 
How are you building your list. You seem to either be creating it "statically" in code or you are doing it through a query. If statically, I suggest you change it to a query. If by query, you are going to have to do a refresh.

HTH Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Terry,

I don't know exactly how to answer your question cause I'm a rookie at this. I created the combo box while I was designing the table. I made the field a combo box and chose value list. After that I typed in the values for the combo box. What I'm trying to plan for now is if I didn't get all of the possible choices in there, then the users can add it to the list at run time.

Hope this makes since and thanks for your reply.
Shane
 
Here's a procedure I did for my daughter to permit the user to add records on the fly to a conbo box using a data table and the procedure adds the inserted data to the table.

This routine will let you add data to a table on which a combo box is based, on the fly. For example, the "bates" table contains numbers and a name. To add a new name to the table while entering data on the form, this routine is attached to a command button (command5) which opens a dialog box for entry of the new name, then adds the new name to the existing table "bates" in the field "name". The combo box must be based upon the table "bates", and "name" must be selected as the listbox field. The same routine can be used to add data to any table in the selected database and recordset.



Private Sub Command5_Click()

Dim varName As Variant 'variable must be declared
varName = InputBox("Enter New Name")

Dim db As Database 'The "AddNew" function works with a recordset, so these
Dim rst As Recordset 'settings are required to make it work.
Set db = CurrentDb
Set rst = db.OpenRecordset("bates", dbOpenDynaset)
With rst
.AddNew
!name = varName
.Update
Me.cboList.Requery 'may not be essential sine this is a table not a query
End With 'probably not a bad idea to include just in case to use
End Sub 'a query rather than a table

Good luck!
 
Hewitt,

Thanks for taking the time to reply and thank you for the code.

Shane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top