NotInList message

Matthew Snook

NW Salmon Database
Local time
Today, 15:52
Joined
Apr 19, 2001
Messages
133
I am writing a procedure for a combo notinlist event. A form for data entry pops up to allow some data manipulation etc. when the event is triggered.

However, I still get the default message box (in addition to my own form) informing the user that "The text you entered isn't an item in the list..." I'd like to use my own popup form instead. How do I get rid of this message? I don't see it in the notinlist event, and I'm not sure where the procedure is located.

Thanks,

Matt
 
Ensure you have the [event proceedure] in the 'notinlist' property on your form. Even though you create code for the message box in the code editor, unless the propery box is set, it defaults to the access msg box.
(Had the same problem myself, and tore my hair out for hours, when I realised what was wrong, my only comment was "You Idiot !"
The other thing worth checking is the response to the error
Private Sub Contractor_NotInList(NewData As String, Response As Integer)

If MsgBox("Contractor Not in Schedule" vbYesNo, "Entry Not Found") = vbYes Then
Equipment.Undo

DoCmd.OpenForm "FrmContractors"

Else
Equipment.Undo
End If
Response = acDataErrContinue

End Sub
hth
Dave

[This message has been edited by Oldsoftboss (edited 12-22-2001).]
 
*I use this function in all my databases to simplify adding the unfound item to a listboxes datasource.
_________________________________________
Public Function Add2Source(tbl As String, fld2update As String, NewData As String) As Integer
'Adds record to the list if not already present
'This only works if there is just one field to update....
Dim strMessage As String
Dim dbs As Database
Dim RstTypes As Recordset
Dim Response As Integer
strMessage = "'" & NewData & "' is not in current list" & _
" To add the item for future reference choose yes, or choose no to select from the present options."
Response = MsgBox(strMessage, vbYesNo, "Not in List")
If Response = vbYes Then
Set dbs = CurrentDb()
Set RstTypes = dbs.OpenRecordset(tbl)
RstTypes.AddNew
RstTypes.Fields(fld2update) = NewData
RstTypes.Update
Add2Source = acDataErrAdded
dbs.Close
Else
Add2Source = acDataErrDisplay
End If
strMessage = ""
Set dbs = Nothing
Set RstTypes = Nothing
End Function
_________________________________________

I then call the function like this:

Private Sub Main_Colours_NotInList(NewData As String, Response As Integer)
Response = Add2Source("tblColours", "fldColours", NewData)
End Sub

If that helps any.

Ian
 

Users who are viewing this thread

Back
Top Bottom