chuckgoss
09-12-2001, 07:35 AM
Hi All,
When I use 'Not In List' with my combo box, I keep getting an informational msg telling me that "The text you entered isn't an item in the list. OK". I've tried to turn off system messages using:
DoCmd.SetWarnings False ..in several places such as after update of the combobox, in Not In List, before and after lines of code that, for now, give me a MsgBox telling me my process worked.
Is there a different way to turn off the informational message?
chuck
charityg
09-12-2001, 08:14 AM
What code are you using in your notinlist event?
chuckgoss
09-12-2001, 08:45 AM
Hi charityg,
right now it's just:
MsgBox "not in list", vbOKCancel
Eventually, it will be an If statement that runs one thing or another depending on the result of the NotInList event.
chuck
Fornatian
09-12-2001, 09:00 AM
Add
Response = acDataErrContinue
after the msgbox.
charityg
09-12-2001, 09:06 AM
why are you using your message box, when Access is essentially saying the same with it's error message?
The way the notinlist event works is:
Private Sub cboName_NotInList(NewData As String, Response As Integer)
' Ask the user whether to add a value to the list.
Dim strMessage As String
Dim dbsMyDatabase As Database
Dim rstMyRecordset As Recordset
strMessage = "Do you want to add '" & NewData & _
"' to the employee list?"
If Confirm(strMessage) Then
' Open the table and add the NewData value.
Set dbsMyDatabase = CurrentDb()
Set rstMyRecordset = dbsMyDatabase.OpenRecordset("MyTable")
rstMyRecordset.AddNew
rstMyRecordset!MyField= NewData
rstMyRecordset.Update
cboName= rstMyRecordset!MyField
Response = acDataErrAdded ' Requery the list.
Else
Response = acDataErrDisplay ' Display the error.
End If
End Sub
[This message has been edited by charityg (edited 09-12-2001).]
chuckgoss
09-12-2001, 09:31 AM
Fornatian,
Thanks for the line of code. It worked great and got me past that problem. Great!
Thanks
CharityG,
2 points here:
1st: A while ago, you so impressed me with your response to a question of mine, that I named a query after you.
2nd: I use the box because it is an easy way for me to tell that Access actually detects that something is not in the list. That's the only reason. My MsgBox will not be in the final code.
I look foreward to trying your code next. My original question, however incompletely worded, should have included a question regarding what the user should do when faced with the fact that the text in the box, is not in the list. You appear to have given me the basis of the code to successfully complete my form...(we'll see!)
Thanks again.
chuck
charityg
09-12-2001, 09:36 AM
Aw shucks! A query named after little ol' ME? I'm blushin'! http://www.access-programmers.co.uk/ubb/smile.gif
But seriously, good luck and let me know if I can help.
~Charity