Oct 20 2021 12:17 AM
I have a simple spreadsheet with 4 columns Column A has the unique field
I am try to insert new records to a SQL Table it works fine except when i add the WHERE parameter inother words where Column A doesnt exist in the SQL Table it must be a quote mark out of place!!
Please put me out of my misery as i need to do the same for updates although that is easier!
SQLStr = "INSERT INTO Customer_Master (GPCustID,RMCCustID, ComID, " & _
"LegalName, Partner) Values(" & _
GPCustID & " , " & RMCCustID & "," & ComID & "," & LegalName & "," & Partner & ")" & _
"WHERE(" GPCustID & " <> " & GPCustID &")"
THANKS!!!!!!
Oct 20 2021 12:50 AM
Try this:
SQLStr = "INSERT INTO Customer_Master (GPCustID, RMCCustID, ComID, " & _
"LegalName, Partner) Values (" & GPCustID & ", " & RMCCustID & _
", " & ComID & ", '" & LegalName & "', '" & Partner & "')" & _
" WHERE " & GPCustID & " Not In (SELECT GPCustID FROM Customer_Master)"
I added single quotes around LegalName and Partner, assuming that those are text fields.
Oct 20 2021 04:25 AM
Oct 20 2021 04:59 AM
Change
MoviesCmd.CommandText = _
SQLStr = "INSERT INTO Customer_Master (GPCustID, RMCCustID, ComID, " & _
"LegalName, Partner) Values (" & GPCustID & ", " & RMCCustID & _
", " & ComID & ", '" & LegalName & "', '" & Partner & "')" & _
" WHERE " & GPCustID & " Not In (SELECT GPCustID FROM Customer_Master)"
to
MoviesCmd.CommandText = _
"INSERT INTO Customer_Master (GPCustID, RMCCustID, ComID, " & _
"LegalName, Partner) Values (" & GPCustID & ", " & RMCCustID & _
", " & ComID & ", '" & LegalName & "', '" & Partner & "')" & _
" WHERE " & GPCustID & " Not In (SELECT GPCustID FROM Customer_Master)"
Oct 22 2021 08:33 AM
Oct 22 2021 12:20 PM
SolutionSorry, I can't help you with that. You might ask in the Access community hub.
Oct 22 2021 12:20 PM
SolutionSorry, I can't help you with that. You might ask in the Access community hub.