I have a few tables in SQL Server, an ODBC link set up on my computer, and an Access Database front end.
In my form I am populating textboxes from another database and a few of the values have Apostrophes in them '.....my SQL INSERT INTO statement is not working on the records that have Apostrophes...
The fields in the SQL database are text fields....Is there anything that I can do to get the SQL update to work? Syntax wise?
Of do I have to go through an remove the Apostrophes' and periods . etc
THis is an example of the textbox value:
Kingston's Meadow
This is the code I am using...
THANKS
Code:
varName = Text82
varOwners_Residence = Text84
varNotice_Expiration = cbo_94
varNotes = Text104
varNotice_Number = Text80
varStatus = Text88
'varResides = ""
'varturn_in = ""
varNotice_Date = cbo_92
varProperty_Address = Text86
varNuisance_Type = Combo98
varAddition_Name = Addition_Name
varRange = Range
varLot = Lot
varBlock = Block
varZip_Code = Zip_Code
varDisplay_PID = PID
varSec_tion = Sec_tion
varTownship = Township
varProperty_City = Text106
varProperty_State = Text108
varProperty_Zip = Text110
varPictureID = Text160
varPicturePath = "\\weeds_database\Weeds_Database_Images\"
varOwner_City = Text194
varOwner_State = Combo202
varOwner_Zip = Text196
Dim varID As Integer
varID = Val(DMax("ID", "dbo_data")) + 1
'MsgBox varID
'===============================================
'===============================================
Dim MySQL As String
MySQL = ""
'MySQL = "INSERT INTO tbl_TRAINING (VendorNumber, FirstName, LastName, Dates, TimeLength, Type, Hours, Experienced_Judge, Attended) values ('" & varVendorNumber & "', '" & varFirstName & "', '" & varLastName & "', '" & varDates & "', '" & varTime & "', '" & varType & "', '" & varHours & "', '" & varExperiencedCheck & "','" & varAttendedCheck & "');"
MySQL = "INSERT INTO dbo_data ("
MySQL = MySQL & "ID,Name,Owners_Residence,Notice_Expiration,Notes,Notice_Number,Status,Notice_Date,Property_Address,Nuisance_Type,Addition_Name,Range,Lot,Block,Zip_Code,Display_PID,Sec_tion,Township,Property_City,Property_State,Property_Zip,PictureID,PicturePath,Owner_City,Owner_State,Owner_Zip"
MySQL = MySQL & ") values ("
MySQL = MySQL & "'" & varID & "','" & varName & "','" & varOwners_Residence & "','" & varNotice_Expiration & "','" & varNotes & "','" & varNotice_Number & "','" & varStatus & "','" & varNotice_Date & "','" & varProperty_Address & "','" & varNuisance_Type & "','" & varAddition_Name & "','" & varRange & "','" & varLot & "','" & varBlock & "','" & varProperty_Zip & "','" & varDisplay_PID & "','" & varSec_tion & "','" & varTownship & "','" & varProperty_City & "','" & varProperty_State & "','" & varZip_Code & "','" & varPictureID & "','" & UpdateFullPath & "','" & varOwner_City & "','" & varOwner_State & "','" & varOwner_Zip & "'"
MySQL = MySQL & ");"
DoCmd.SetWarnings False
'MsgBox MySQL
DoCmd.RunSQL MySQL