Hi
I am currently trying to build a case management database which involves
students and different areas of interest: Presecreening, Pre-entry, surveys
at 6 month intervals, current information, health needs, mental needs, risk
factors, care, treatment, etc.
I was a bit thrown off when some NotInList events sorted and some didn't.
They are all using the same code. Each time I copied the events I made the
necessary changes.
This is the code I used for the NotInEvent procedure for adding a new
hometown:
Private Sub Hometown_NotInList(NewData As String, Response As Integer)
On Error GoTo Insert_Error
intAnswer = MsgBox("This city is not currently in the list." & vbCrLf & _
"Would you like to add this city to the list now?" _
, vbQuestion + vbYesNo, "This city")
If intAnswer = vbYes Then
strSQL = "INSERT INTO CB_City([City]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.SetWarnings True
MsgBox "This city has been added to the list." _
, vbInformation, "NewData"
Response = acDataErrAdded
End If
Exit Sub
Insert_Error:
MsgBox "The attempted insert produced the following error:" & vbCrLf & Err
Response = acDataErrContinue
End Sub
The changes I would make is to the message box statement and the table and
field name.
Thanks