Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add to NotInList Without Confirmation.

Status
Not open for further replies.

boxboxbox

Technical User
Apr 22, 2003
108
US
I know how to add a value to the value list for a NotInList event, but can I do this without having a message box popup to confirm? I would much rather have it be added without the user having to say OK.

I can't figure out which, if any, lines I can take out to get this. Here is my code:

Private Sub RcptNum_NotInList(NewData As String, Response As Integer)
Dim vResponse As Integer
vResponse = MsgBox("Data entered '" & NewData & "' is not contained in current list." & Chr(13) & "Do you wish to add it to the file?", 36, "New Data Prompt")
If vResponse = 6 Then
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("purchase receipts", dbOpenDynaset)
MyRS.AddNew
MyRS("rcptnum") = NewData 'put any and all field data expressions here. . .
MyRS.Update
MyRS.Close
MyDB.Close
Response = DATA_ERRADDED
Else
Me![FindCustomer] = Null
Response = DATA_ERRCONTINUE
End If
End Sub


Thanks!
 
Looks like code I posted a while back so I bet I can fix it for you:

Private Sub RcptNum_NotInList(NewData As String, Response As Integer)
Dim vResponse As Integer
vResponse = MsgBox("Data entered '" & NewData & "' is not contained in current list." & Chr(13) & "Do you wish to add it to the file?", 36, "New Data Prompt")
If vResponse = 6 Then
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("purchase receipts", dbOpenDynaset)
MyRS.AddNew
MyRS("rcptnum") = NewData 'put any and all field data expressions here. . .
MyRS.Update
MyRS.Close
MyDB.Close
Response = DATA_ERRADDED
Else
Me![FindCustomer] = Null
Response = DATA_ERRCONTINUE
End If
End Sub

Just remove the RED VBA code.


Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Whoohoo! That did it. I had kind of guessed that those lines needed out, but the chances of me randomly typing "response = data_errcontinue" at the end were pretty slim.

That was indeed your code (should I give little credit notices on things like that?{: ) -- it was the code I liked best after reading some other posts, FAQs, etc.

Thanks again, and here's another star!
 
Hey, glad to be of help. Thanks for the Star!!

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top