T
Todd K.
I have the following code in a Form:
'Declare variables
Dim strFundType As String
Dim strContact As String
Dim strCounty As String
Dim strProjTitle As String
Dim strProjID As String
Dim strApplicant As String
Dim curProj_Alloc As Currency
Dim strProj_Desc As String
Dim curBal As Currency
Dim curSpent As Currency
Dim strvalues As String
'Set variables
strFundType = Me.Grant_Type
strContact = Me.Personnel
strCounty = Me.County
strProjTitle = Replace(Me.Project_Name, "'", "")
strProjID = Me.Project_No
strApplicant = Me.Applicant
curProj_Alloc = Me.Fund_Amt
strProj_Desc = ",'" & Me.Project_Desc & "'"
curBal = Me.RemBal
curSpent = curProj_Alloc - curBal
strvalues = "'" & [strFundType] & " ','" & [strContact] & "','" &
[strCounty] & "','" & [strProjTitle] & "','" & [strProjID] & "','" &
[strApplicant] & "'," & [curProj_Alloc] & "," & [curBal] & "," & [curSpent]
' Run the dataset query
DoCmd.RunSQL "DELETE FROM TblRptCompletion;"
DoCmd.RunSQL "INSERT INTO TblRptCompletion
(Fund,Contact,County,ProjectName,ProjectID,Applicant,ProjectAllocation,
Balance, Spent,ProjectDescription) VALUES (" & [strvalues] & [strProj_Desc] &
");"
Sometimes it works great, sometimes I get the error: "Run-time error '8152':
string or binary data would be truncated" I have no idea what this means,
but since it is a string data type and I'm nowhere near the 65,000 character
limit, I know it's not that the string is too long. When I debug, it
highlights the "INSERT INTO..." line.
'Declare variables
Dim strFundType As String
Dim strContact As String
Dim strCounty As String
Dim strProjTitle As String
Dim strProjID As String
Dim strApplicant As String
Dim curProj_Alloc As Currency
Dim strProj_Desc As String
Dim curBal As Currency
Dim curSpent As Currency
Dim strvalues As String
'Set variables
strFundType = Me.Grant_Type
strContact = Me.Personnel
strCounty = Me.County
strProjTitle = Replace(Me.Project_Name, "'", "")
strProjID = Me.Project_No
strApplicant = Me.Applicant
curProj_Alloc = Me.Fund_Amt
strProj_Desc = ",'" & Me.Project_Desc & "'"
curBal = Me.RemBal
curSpent = curProj_Alloc - curBal
strvalues = "'" & [strFundType] & " ','" & [strContact] & "','" &
[strCounty] & "','" & [strProjTitle] & "','" & [strProjID] & "','" &
[strApplicant] & "'," & [curProj_Alloc] & "," & [curBal] & "," & [curSpent]
' Run the dataset query
DoCmd.RunSQL "DELETE FROM TblRptCompletion;"
DoCmd.RunSQL "INSERT INTO TblRptCompletion
(Fund,Contact,County,ProjectName,ProjectID,Applicant,ProjectAllocation,
Balance, Spent,ProjectDescription) VALUES (" & [strvalues] & [strProj_Desc] &
");"
Sometimes it works great, sometimes I get the error: "Run-time error '8152':
string or binary data would be truncated" I have no idea what this means,
but since it is a string data type and I'm nowhere near the 65,000 character
limit, I know it's not that the string is too long. When I debug, it
highlights the "INSERT INTO..." line.