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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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 | |
|
|