Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / June 2006

Tip: Looking for answers? Try searching our database.

Not In List Event--Adding to Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian ><> - 06 Jun 2006 19:36 GMT
I am using the following code for adding to a Combo Box when an item is
entered that's not in the list:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
   On Error GoTo Customer_NotInList_Err
   Dim intAnswer As Integer
   Dim strSQL As String
   intAnswer = MsgBox("Customer " & Chr(34) & NewData & _
       Chr(34) & " does not exist." & vbCrLf & _
       "Would you like to add it?" _
       , vbQuestion + vbYesNo, "Customers")
   If intAnswer = vbYes Then
       strSQL = "INSERT INTO Customers_Table(CU_Customer) " & _
                "VALUES ('" & NewData & "');"
       DoCmd.SetWarnings False
       DoCmd.RunSQL strSQL
       DoCmd.SetWarnings True
       MsgBox "The new customer has been added." _
           , vbInformation, "Customers"
       Response = acDataErrAdded
   Else
       MsgBox "Please choose an existing customer then." _
           , vbInformation, "Customers"
       Response = acDataErrContinue
   End If
Customer_NotInList_Exit:
   Exit Sub
Customer_NotInList_Err:
   MsgBox Err.Description, vbCritical, "Error"
   Resume Customer_NotInList_Exit
End Sub

It's not working and I'm not sure why...  When I type a new value into my
form I get the "Customer ___ does not exist. Would you like to add it?"
message.  If I select No, I get the proper message.  If I select yes, it
doesn't add it to the table.  Instead I get the follow error message:

Cannot find output table 'Customers_Table'.

But that is the name of my table!
John Spencer - 06 Jun 2006 21:17 GMT
Try adding a space between Customers_Table and (CU_Customer)

strSQL = "INSERT INTO Customers_Table (CU_Customer) " & _
                "VALUES ('" & NewData & "');"

Double check the name of the table.  Is it Customers  or is it
Customer_Table or is it Customers Table?  If the last, try [Customers Table]
in the query string.

>I am using the following code for adding to a Combo Box when an item is
> entered that's not in the list:
[quoted text clipped - 36 lines]
>
> But that is the name of my table!
Christian ><> - 06 Jun 2006 21:28 GMT
I had the name right and I had tried the space before...  THE BRACKETS
WORKED!  THANK YOU!!!!!

> Try adding a space between Customers_Table and (CU_Customer)
>
[quoted text clipped - 45 lines]
> >
> > But that is the name of my table!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.