I'm using Access 2003 connecting to SQL server 2k via ODBC. The codes below work fine when I use ODBC connection and Link tables. However, when I create a Project, import the form and run it, i receive this message: "Line 1: Incorrect syntax near '!'." Can someone please help identify why the codes work in an ODBC connection but not in a Project? I want to create a project so that the data entry people do not have to supply the username and password when they're entering data. Your help is greatly appreciated.
strSQLAppend = "INSERT INTO tbl_Data ([Community],[Bldg],[Lot],[Task],[Vendor],[GeneralNotes],[InspDate],[Notes],[CrewName])" & _
"SELECT [Forms]![frmDataEntry]![TxtCom],[Forms]![frmDataEntry]![TxtBldg],[Forms]![frmDataEntry]![TxtLot],[Forms]![frmDataEntry]![TxtTask],[Forms]![frmDataEntry]![TxtVend],[Forms]![Forms]![frmDataEntry]![TxtGeneralNote],[Forms]![frmDataEntry]![TxtBldrInspectionDt],[Forms]![frmDataEntry]![TxtNote],[Forms]![frmDataEntry]![TxtCrewName]"
DoCmd.SetWarnings (warningsoff)
DoCmd.RunSQL strSQLAppend
DoCmd.SetWarnings (warningson)
Me.CboComm = ""
Me.TxtBldg = ""
Me.TxtLot = ""
Me.CboTask = ""
Me.CboVendor = ""
Me.TxtGeneralNote = ""
Me.TxtBldrInspectionDt = ""
Me.TxtNote = ""
Me.TxtCrewName = ""
Thanks
strSQLAppend = "INSERT INTO tbl_Data ([Community],[Bldg],[Lot],[Task],[Vendor],[GeneralNotes],[InspDate],[Notes],[CrewName])" & _
"SELECT [Forms]![frmDataEntry]![TxtCom],[Forms]![frmDataEntry]![TxtBldg],[Forms]![frmDataEntry]![TxtLot],[Forms]![frmDataEntry]![TxtTask],[Forms]![frmDataEntry]![TxtVend],[Forms]![Forms]![frmDataEntry]![TxtGeneralNote],[Forms]![frmDataEntry]![TxtBldrInspectionDt],[Forms]![frmDataEntry]![TxtNote],[Forms]![frmDataEntry]![TxtCrewName]"
DoCmd.SetWarnings (warningsoff)
DoCmd.RunSQL strSQLAppend
DoCmd.SetWarnings (warningson)
Me.CboComm = ""
Me.TxtBldg = ""
Me.TxtLot = ""
Me.CboTask = ""
Me.CboVendor = ""
Me.TxtGeneralNote = ""
Me.TxtBldrInspectionDt = ""
Me.TxtNote = ""
Me.TxtCrewName = ""
Thanks