You’re facing a limitation of Access SQL text parameters. They can not accommodate string values longer than 255 characters.
Here is a simple example which demonstrates the problem.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strUpdate As String
Dim strLongString As String
strLongString = String(300, "x")
strUpdate = "UPDATE tblFoo SET memo_field = [pLongString] WHERE id=2;"
Set db = CurrentDb
Set qdf = db.CreateQueryDef(vbNullString, strUpdate)
qdf.Parameters("pLongString").Value = strLongString
qdf.Execute dbFailOnError
That code triggers error #3271, “Invalid property value.” … the same error you’re seeing.
If I change the UPDATE
statement to include a PARAMETERS
clause like this …
strUpdate = "PARAMETERS [pLongString] LongText;" & vbCrLf & _
"UPDATE tblFoo SET memo_field = [pLongString] WHERE id=2;"
… the outcome is still error #3271.
I don’t believe there is any way to overcome that Access SQL limitation.
So if the length of your text parameter value is greater than 255 characters, you need a different method.
A DAO.Recordset
approach is a simple alternative to store long text strings in a field.
Dim rs As DAO.Recordset
Dim strSelect
strSelect = "SELECT id, memo_field FROM tblFoo WHERE id=2;"
Set rs = db.OpenRecordset(strSelect)
With rs
If Not (.BOF And .EOF) Then
.Edit
!memo_field.Value = strLongString
.Update
End If
.Close
End With