Search code examples
mysqlsqlerror-handlingms-access-2010insertion

Error with SQL Insert Into Access 2010


I may have found the problem but at this point trying to correct it has been the issue. I have checked the source table and the insertion table and both have the correct fields/type values needed for this insert. So, my question is why am I getting an appending error in one row with this statement? I believe the only Yes/No box ( i.e. Ramp ) is causing this headache. How would I go about correcting this? Thank you very much here is the insertion statement.

DoCmd.RunSQL "INSERT INTO tblReportFinal(ProjectNo, RouteType, Route, StreetType, Direction1, Direction2, CommonDesignation, " & _
    "FromRouteType, FromRoute, FromStreetType, FromCommonDesignation, ToRouteType, ToRoute,ToStreetType, ToCommonDesignation, Ramp, RampDirection, " & _
    "Municipality, StartDate, StopDate, ImpactOnTravel, SuggestionsToMotorists, TrafficAlert, OtherComments, WidthRestriction, " & _
    "ProjectStatus, ContractNo, Contractor, PercentComplete, GeneralOfficePhoneNumber, GeneralMobilPhoneNumber, GeneralHomePhoneNumber, ElectricalContractor, " & _
    "ElectricalPhoneNumber, ContractorRep1Name, ContractorRep1OfficePhone, ContractorRep1MobilPhone, ContractorRep1HomePhone, ContractorRep2Name, ContractorRep2OfficePhone, ContractorRep2MobilPhone, " & _
    "ContractorRep2HomePhone, ConsultantFirstName, ConsultantLastName, ConsultantOfficePhoneNumber, ConsultantMobilPhoneNumber, ConsultantHomePhoneNumber, ResidentFirstName, ResidentLastName, " & _
    "ResidentOfficePhoneNumber, ResidentHomePhoneNumber, ResidentMobilePhoneNumber, SupervisorFirstName, SupervisorLastName, SupervisorOfficePhoneNumber, SupervisorMobilPhoneNumber, TrafficControlCompanyName, TrafficControlContactName, TrafficControlPhoneNumber, RouteTypeOrderBy) " & _
    "VALUES('" & rsReportLoc("ProjectNo") & "','" & rsReportLoc("RouteType") & "','" & rsReportLoc("Route") & "','" & rsReportLoc("StreetType") & "','" & rsReportLoc("Direction1") & "','" & _
    rsReportLoc("Direction2") & "','" & rsReportLoc("CommonDesignation") & "','" & rsReportLoc("FromRouteType") & "','" & rsReportLoc("FromRoute") & "','" & rsReportLoc("FromStreetType") & "', '" & _
    rsReportLoc("FromCommonDesignation") & "','" & rsReportLoc("ToRouteType") & "','" & rsReportLoc("ToRoute") & "','" & rsReportLoc("ToStreetType") & "','" & rsReportLoc("ToCommonDesignation") & "', '" & rsReportLoc("Ramp") & "', '" & rsReportLoc("RampDirection") & "', '" & _
    rsIn("Municipality") & "', '" & _
    rsIn("StartDate") & "','" & rsIn("StopDate") & "','" & rsIn("ImpactOnTravel") & "','" & rsIn("SuggestionsToMotorists") & "','" & rsIn("TrafficAlert") & "','" & _
    rsIn("OtherComments") & "','" & rsIn("WidthRestriction") & "','" & rsIn("ProjectStatus") & "','" & rsIn("ContractNo") & "','" & rsIn("Contractor") & "', '" & _
    rsIn("PercentComplete") & "','" & rsIn("GeneralOfficePhoneNumber") & "','" & rsIn("GeneralMobilPhoneNumber") & "','" & rsIn("GeneralHomePhoneNumber") & "','" & rsIn("ElectricalContractor") & "', '" & _
    rsIn("ElectricalPhoneNumber") & "','" & rsIn("ContractorRep1Name") & "','" & rsIn("ContractorRep1OfficePhone") & "','" & rsIn("ContractorRep1MobilPhone") & "','" & rsIn("ContractorRep1HomePhone") & "', '" & _
    rsIn("ContractorRep2Name") & "','" & rsIn("ContractorRep2OfficePhone") & "','" & rsIn("ContractorRep2MobilPhone") & "','" & rsIn("ContractorRep2HomePhone") & "','" & rsIn("ConsultantFirstName") & "', '" & _
    rsIn("ConsultantLastName") & "','" & rsIn("ConsultantOfficePhoneNumber") & "','" & rsIn("ConsultantMobilPhoneNumber") & "','" & rsIn("ConsultantHomePhoneNumber") & "','" & rsIn("ResidentFirstName") & "', '" & _
    rsIn("ResidentLastName") & "','" & rsIn("ResidentOfficePhoneNumber") & "','" & rsIn("ResidentHomePhoneNumber") & "','" & rsIn("ResidentMobilePhoneNumber") & "','" & rsIn("SupervisorFirstName") & "','" & rsIn("SupervisorLastName") & "', '" & _
    rsIn("SupervisorOfficePhoneNumber") & "','" & rsIn("SupervisorMobilPhoneNumber") & "','" & rsIn("TrafficControlCompanyName") & "','" & rsIn("TrafficControlContactName") & "','" & rsIn("TrafficControlPhoneNumber") & "', '" & RouteTypeOrder & "')"

Solution

  • If Ramp is an Yes/No type why are you using a String value?

    , '" & rsReportLoc("Ramp") & "', 
    

    It should be simply

    , " & rsReportLoc("Ramp") & ",