|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error 8152String or binary data would be truncated. Here is my statement written with VBA in an Access project. Both datatypes are nvarchar Private Sub cmdCreateJob_Click() Dim strJcn As String Dim strParcTag As String Dim strSql As String strJcn = 999999 strParcTag = Me.cboEquipID.Column(0) strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ & " VALUES ('strJcn','strParcTag')" DoCmd.RunSQL strSql End Sub Can anyone see what I'm doing wrong? Thanks. Can you post your DDL for table ESR?
Perayu Show quote "AkAlan" <AkA***@discussions.microsoft.com> wrote in message news:E21FB5F9-31A7-4FA4-89AD-49F37A3CA0E7@microsoft.com... > I'm trying to add a record to a table and am getting Error 8152: > String or binary data would be truncated. > > Here is my statement written with VBA in an Access project. > Both datatypes are nvarchar > > Private Sub cmdCreateJob_Click() > > Dim strJcn As String > Dim strParcTag As String > Dim strSql As String > > strJcn = 999999 > strParcTag = Me.cboEquipID.Column(0) > > strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ > & " VALUES ('strJcn','strParcTag')" > > DoCmd.RunSQL strSql > > End Sub > > Can anyone see what I'm doing wrong? Thanks. > > > > > > Check the ESR_JCN column length and strJcn string length
and ESR_PARCTAG column length and strParcTag string length The data length must be longer than column length -- Show quoteThanks & Rate the Postings. -Ravi- "AkAlan" wrote: > I'm trying to add a record to a table and am getting Error 8152: > String or binary data would be truncated. > > Here is my statement written with VBA in an Access project. > Both datatypes are nvarchar > > Private Sub cmdCreateJob_Click() > > Dim strJcn As String > Dim strParcTag As String > Dim strSql As String > > strJcn = 999999 > strParcTag = Me.cboEquipID.Column(0) > > strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ > & " VALUES ('strJcn','strParcTag')" > > DoCmd.RunSQL strSql > > End Sub > > Can anyone see what I'm doing wrong? Thanks. > > > > > > It looks like this VB(?) code is wrong: " VALUES ('strJcn','strParcTag')".
You are inserting 'strJcn', not the value of strJcn, to ESR_JCN column. You need to try something like " VALUES ('" + integerToString(strJcn) + "', '" + strParcTag+ "')". But I am not sure what the syntact is for concatinate the single quots in VB. Perayu Show quote "AkAlan" <AkA***@discussions.microsoft.com> wrote in message news:E21FB5F9-31A7-4FA4-89AD-49F37A3CA0E7@microsoft.com... > I'm trying to add a record to a table and am getting Error 8152: > String or binary data would be truncated. > > Here is my statement written with VBA in an Access project. > Both datatypes are nvarchar > > Private Sub cmdCreateJob_Click() > > Dim strJcn As String > Dim strParcTag As String > Dim strSql As String > > strJcn = 999999 > strParcTag = Me.cboEquipID.Column(0) > > strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ > & " VALUES ('strJcn','strParcTag')" > > DoCmd.RunSQL strSql > > End Sub > > Can anyone see what I'm doing wrong? Thanks. > > > > > > Ok I got everything to work up until I add the datOpenDate field. It only
puts 12:00 AM in the record when I put 1 mar 06 in the form. Here is what I have so far: I have tried formatting the datefield but no go. Thanks, strJcn = "'" & NextJCN() & "'" strParcTag = "'" & Me.cboEquipID.Column(0) & "'" strPerfWc = "'" & Me.cboPWC & "'" strRptby = "'" & Me.cboReportedBy.Column(0) & "'" strDisc = "'" & Me.txtDisc & "'" datOpenDate = “’†& Me.txtOpenDate & “’†strSQL = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG,ESR_DISC,ESR_RPTBY,ESR_OPEN_DATE)" _ & " VALUES (" & strJcn & "," & strParcTag & "," & strDisc & "" _ & "," & strRptby & ", " & datOpenDate & " )" DoCmd.RunSQL strSQL Show quote "Perayu" wrote: > It looks like this VB(?) code is wrong: " VALUES ('strJcn','strParcTag')". > You are inserting 'strJcn', not the value of strJcn, to ESR_JCN column. You > need to try something like " VALUES ('" + integerToString(strJcn) + "', '" > + strParcTag+ "')". But I am not sure what the syntact is for concatinate > the single quots in VB. > > Perayu > > "AkAlan" <AkA***@discussions.microsoft.com> wrote in message > news:E21FB5F9-31A7-4FA4-89AD-49F37A3CA0E7@microsoft.com... > > I'm trying to add a record to a table and am getting Error 8152: > > String or binary data would be truncated. > > > > Here is my statement written with VBA in an Access project. > > Both datatypes are nvarchar > > > > Private Sub cmdCreateJob_Click() > > > > Dim strJcn As String > > Dim strParcTag As String > > Dim strSql As String > > > > strJcn = 999999 > > strParcTag = Me.cboEquipID.Column(0) > > > > strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ > > & " VALUES ('strJcn','strParcTag')" > > > > DoCmd.RunSQL strSql > > > > End Sub > > > > Can anyone see what I'm doing wrong? Thanks. > > > > > > > > > > > > > > > It looks like you have typo here: datOpenDate = "'" & Me.txtOpenDate & "'".
"'" should be "'". Perayu Show quote "AkAlan" <AkA***@discussions.microsoft.com> wrote in message news:2ABA6908-E32F-4C09-9BC0-BCF089F15C0F@microsoft.com... > Ok I got everything to work up until I add the datOpenDate field. It only > puts 12:00 AM in the record when I put 1 mar 06 in the form. Here is what > I > have so far: > I have tried formatting the datefield but no go. Thanks, > strJcn = "'" & NextJCN() & "'" > strParcTag = "'" & Me.cboEquipID.Column(0) & "'" > strPerfWc = "'" & Me.cboPWC & "'" > strRptby = "'" & Me.cboReportedBy.Column(0) & "'" > strDisc = "'" & Me.txtDisc & "'" > datOpenDate = "'" & Me.txtOpenDate & "'" > > strSQL = "INSERT INTO ESR > (ESR_JCN,ESR_PARCTAG,ESR_DISC,ESR_RPTBY,ESR_OPEN_DATE)" _ > & " VALUES (" & strJcn & "," & strParcTag & "," & strDisc & "" _ > & "," & strRptby & ", " & datOpenDate & " )" > > DoCmd.RunSQL strSQL > > > "Perayu" wrote: > >> It looks like this VB(?) code is wrong: " VALUES >> ('strJcn','strParcTag')". >> You are inserting 'strJcn', not the value of strJcn, to ESR_JCN column. >> You >> need to try something like " VALUES ('" + integerToString(strJcn) + "', >> '" >> + strParcTag+ "')". But I am not sure what the syntact is for concatinate >> the single quots in VB. >> >> Perayu >> >> "AkAlan" <AkA***@discussions.microsoft.com> wrote in message >> news:E21FB5F9-31A7-4FA4-89AD-49F37A3CA0E7@microsoft.com... >> > I'm trying to add a record to a table and am getting Error 8152: >> > String or binary data would be truncated. >> > >> > Here is my statement written with VBA in an Access project. >> > Both datatypes are nvarchar >> > >> > Private Sub cmdCreateJob_Click() >> > >> > Dim strJcn As String >> > Dim strParcTag As String >> > Dim strSql As String >> > >> > strJcn = 999999 >> > strParcTag = Me.cboEquipID.Column(0) >> > >> > strSql = "INSERT INTO ESR (ESR_JCN,ESR_PARCTAG)" _ >> > & " VALUES ('strJcn','strParcTag')" >> > >> > DoCmd.RunSQL strSql >> > >> > End Sub >> > >> > Can anyone see what I'm doing wrong? Thanks. >> > >> > >> > >> > >> > >> > >> >> >> |
|||||||||||||||||||||||