Hello everyone.
I am having a strange error. This code block used to work fine. So here is what I did, I changed the part of the code that reads CurrentName from CurrentTM_ID, and that seems to have caused the error. Any suggestions?
Private Function AddNewCustomer() As String
Dim Customer As String
Dim custRS As New ADODB.Recordset
'allow the user to add New Customers to their PERSONAL customer list
Customer = InputBox("Create a New Customer", "New Customer")
If Customer <> "" Then
If conn <> "" Then
If conn.State = 1 Then
CreateConnection
End If
Else
CreateConnection
End If
'verify the the newly entered customer does NOT already exist in the database as a customer for this TM before actually adding
' This is one of the few places where we will reference TM ID without referencing Sales Org
If Not FindCustomer(Customer) Then
conn.Execute "Insert into Customer (CustomerName, TM_ID) Values('" _
& Replace(Customer, "'", "''") & "','" & Sheets(VALIDATIONS).Range("CurrentTMID").Value & "')" <--------------------- Error line colored in red
Application.Wait Now + TimeValue("00:00:01")
LoadCustomers
AddNewCustomer = Customer
Else
MsgBox "You already have a Customer by that Name", vbOKOnly, "Customer exists"
End If
End If
End Function
Bookmarks