This is the beginning of what will probably be a two-part question. I've tried several variations on working code I've used in the past, and scoured the internet until my eyes fell out (I'm better now), but I still can't get it working.
I have a combobox (cboVstrName) on a form using the field "VstrName" as the row source from tblVstr (other fields in this table are "VstrID {PK, autonumber} and VstrCompany). Limit To List is set to "Yes". I'm trying to add the following code to the "Not In List" to add the name to the table, so it will show up in the dropdown box the next time...
Private Sub cboVstrName_NotInList(NewData As String)
'Adds visitor name to tblVstr if not already on dropdown list
Dim strSQL As String
DoCmd.SetWarnings False
strSQL = "INSERT INTO tblVstr (VstrName)"
strSQL = strSQL & "Select """ & NewData & """;"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded
End Sub
but I get this error...
How can I make this work?