A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Not In List CBO Help



 
 
Thread Tools Display Modes
  #1  
Old October 28th, 2008, 08:22 PM posted to microsoft.public.access
Stockwell43
external usenet poster
 
Posts: 579
Default Not In List CBO Help

Hello,

I have a CBO on my form named Catagory. It is bound to a table called
tblCatagory. I tried to place this code in the On Not In List event of the
CBO and when I typed in a catagory not in the table, not only did not warn me
but also it did not save it to the table. can someone help me please?
This is the code I used from a site on the internet:

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

On Error GoTo cboCatagory_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The Catagory " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Acme Oil and Gas")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tblCatagory([Catagory]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Catagory has been added to the list." _
, vbInformation, "Acme Oil and Gas"
Response = acDataErrAdded
Else
MsgBox "Please choose a Catagory from the list." _
, vbInformation, "Acme Oil and Gas"
Response = acDataErrContinue
End If
cboCatagory_NotInList_Exit:
Exit Sub
cboCatagory_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCatagory_NotInList_Exit
End Sub

Thank you any help you can offer!!!!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.