notinlist event procedure not working

S

SFC Traver

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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top