Problem with on NotInList (1 Viewer)

bennybee

Registered User.
Local time
Today, 21:01
Joined
Jan 13, 2004
Messages
50
Im trying to use the on NotInList value to update a table that i have.

at the moment im using the onUpdate value of another field to determine the record source of this field (The one that im using the on NotInList value).

The code that i have is this:

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

Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Dim NewID As String

On Error GoTo Err_Nature_Type_NotInList

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

If Subject = "Commission" Then

' Confirm that the user wants to add the new nature.
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
' If the user chose not to add a new nature, set the Response
' argument to suppress an error message and undo changes.
Response = acDataErrContinue
' Display a customized message.
MsgBox "Please try again."
Else
' If the user chose to add a new nature, open a recordset
' using the Commission_Nature table.
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Commission_Nature", dbOpenDynaset)

' Ask the user to input a new nature.
Msg = "Please enter Commission Nature" & vbCr & ""
NewID = InputBox(Msg)
Rs.FindFirst BuildCriteria("Commission_Nature", dbText, NewID)
' If the NewID already exists, ask for another new unique
' nature
' Create a new record.
Rs.AddNew
' Assign the NewID to the Commission_Nature field.
Rs![Commission_Nature] = NewID

' Save the record.
Rs.Update

' Set Response argument to indicate that new data is being added.
Response = acDataErrAdded

End If

Exit_Nature_Type_NotInList:
Exit Sub
Err_Nature_Type_NotInList:
' An unexpected error occurred, display the normal error message.
MsgBox Err.Description
' Set the Response argument to suppress an error message and undo
' changes.
Response = acDataErrContinue
End If
.... etc etc.... for each different value in the subject box.


now when i enter a value into the Nature_Type field that is not in the list and then tab accorss, it gives me this error

"Cannot find project or library".
it will then open up the debugger and highlight the first line of code "Private Sub Nature_Type_NotInList(NewData As String, Response As Integer)" in yellow. and then highlights
"Dim Db As DAO.Database" in normal windows highlighting.

what is the problem??
i copied this from an example on the web. but it doesnt seem to work for me.

how can i fix this??
 

Users who are viewing this thread

Top Bottom