Row source & control source on a form; PLEASE help if you can...

A

ac512

Hello

Apologies in advance if this is a silly question???!!!
I have created a form in Access 2002, and one of the fields in my form is a
combo box which the users will select a value from. The combo box has a
table as the row source, which I will call tblLookup. If the users cannot
find a value specific to their requirements, they can type in their own
value. I am trying to find a way to be able to add any new values typed by
users in the table (tblLookup). So basically, if the users cannot find a
value in the combo box, they type a new value and this new value will save in
the table.

Hope this makes sense
Any help/ideas/suggestions would be greatly appreciated
Thanking you in advance...

AC
 
A

Albert D.Kallal

You can set the limit to yes for the combo box.

For the not in list event, you can use the following code:

Dim strSql As String
If MsgBox(NewData & " not in list, add?", _
vbYesNo + vbQuestion) = vbYes Then
strSql = "insert into tblStudents (name) values('" & NewData & "')"
CurrentDb.Execute strSql
Response = acDataErrAdded
End If

Note I used a table name of tblStudents, and field name of Sname. So, just
change the table name, and the field to whatever you used.
 
Top