I'd still be interested in why I can't get my own code to work, which
now looks like this:
Private Sub CboDeptName_NotInList(NewData As String, Response As
Integer)
Dim byt As Byte, dirid
This Dims dirid as a Variant since you don't specify an As. If it should be a
Long Integer then it would be best to Dim it as Long.
dirid = Me.DirectoryID
byt = MsgBox("Do you want to add this new Business Department to
the Lookup Table?", vbYesNo)
If byt = vbYes Then
Response = acDataErrAdded
CurrentDb.Execute "INSERT INTO & zDepartments & ([DeptName],
zDepartments is not visibly defined here, for one thing, and your ampersands
seem to be missing. What is zDepartments? If it's a tablename in a string
variable you whould be using something like
CurrentDb.Execute "INSERT INTO [" & zDepartments & "] ([DeptName],
[DirectoryID]) VALUES ('" & NewData & "', " & dirid & " );"
End If
End Sub
You say "not working" - what's not working? You chose to ignore my earlier
suggestion to use dbFailOnError to trap query errors I see; if you're still
getting an error in the query (likely given the above!) it will silently fail
and you'll not see any error message.
John W. Vinson [MVP]