As I enter values, I would like them to be updated to a list to be used in a combobox

hijfte

Registered User.
Local time
Yesterday, 20:36
Joined
Mar 19, 2009
Messages
23
I have fields in my form (frmPicture) called Name, City, State, Country, Color, and backgroundColor. Many of these values will be used multiple times, and I don't want to type them out every time. I don't know all the values at the beginning of the project, so can't just create a list. I would like a list to be created as I type these in, which updates the selections for a combobox for each field. Any ideas?
 
Search here on "notinlist", the event you can use to add new items to a combo's rowsource.
 
You could use something like the following in your Not In List event of your combo box:

Dim db As DAO.Database
Dim newrec As DAO.Recordset
Dim strMsg As String

strMsg = "'" & NewData & "' is not an specified First Aid Action " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this first aid action to Eyes group?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type it."

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new First Aid Action?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set newrec = db.OpenRecordset("Your_Table_Name", dbOpenDynaset)
On Error Resume Next
newrec.AddNew
newrec!Description = NewData '<<<<<This is the field name in the table you want to save to.

newrec.Update

If err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If

Set newrec = Nothing
Set db = Nothing

It saves the new value to the field that the combo box displays you would need to amend the message to suit your application.

Good luck. John :)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom