notinlist event procedure not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having problem with the event procedure to add new values to a combo list
in a form. The form is tied to table (Data) and the combo list gets it's data
from another table (Diagnosis). Relationships are set between the two tables.
I've done the below and can't get it to work. What am i doing wrong???

Private Sub Admitting_Diagnosis_NotInList(NewData As String, Response As
Integer)

Dim db As Database
Set db = CurrentDb

If MsgBox("Do you want to add this value to the list?",
vbYesNo+vbQuestion,"Add new value?") = vbYes Then

db.Execute "INSERT INTO tbl.Diagnosis (Field1) VALUES (""" & NewData &
""")", dbFailOnError

Response = acDataErrAdded

Else

Me.Admitting_Diagnosis.Undo

Response = acDataErrContinue

End If

db.Close
Set db = Nothing

End Sub

Thanks
 
SFC Traver said:
I'm having problem with the event procedure to add new values to a combo list
in a form. The form is tied to table (Data) and the combo list gets it's data
from another table (Diagnosis). Relationships are set between the two tables.
I've done the below and can't get it to work. What am i doing wrong??? [snip]
db.Execute "INSERT INTO tbl.Diagnosis (Field1) VALUES (""" & NewData &
""")", dbFailOnError
[snip]


You have an illegal table name in the query. Either the
tbl. or just the . should be removed.

Also check the table and replace Field1 with the actual name
of the field.
 
Back
Top