Question : UPDATING BINARY FIELD data with MS-ACCESS using VBA

I am editing an existing MS-ACCESS database which incudes one field of type BINARY(400).  I am able to READ the data from the database byte by byte.  But I am getting SYNTAX errors when trying to UPDATE the field using DoCmd.RunSQL within VBA.  

What is the best way to WRITE to an ACCESS  BINARY field from VBA?

Any help or sample code would be appreciated.

Answer : UPDATING BINARY FIELD data with MS-ACCESS using VBA

You are creating a recordset with that code.  I thought of using a recordset but did not know how to handle binary in a recordset.  Your code shows that.  To write to a recordset, you use an append statement, set the field, then use a refresh statement:

QueryBinary1.Append
For TagNumber = 0 To 399
  QueryBinary1!FFolderInfoArray(TagNumber) = RawTag(TagNumber)
Next TagNumber
QueryBinary1.Refresh

So, my guess:
Dim RawTag(400) As Byte
Dim WordInserted As Boolean

WordInserted = False
Set cnn1 = CurrentProject.Connection
With QueryBinary1
    .ActiveConnection = cnn1
    .Open "[SingleRecordBinaryField]"
    .MoveFirst
    Do
        For TagNumber = 0 To 399
          RawTag(TagNumber) = !FFolderInfoArray(TagNumber)
        Next TagNumber

        .Append
        !FFolderInfoArray(0) = YourFirstByte  
        !FFolderInfoArray(1) = YourSecondByte  
        !FFolderInfoArray(2) = YourThirdByte  
        !FFolderInfoArray(3) = YourForthByte  
        For TagNumber = 4 To 399 Step 4
           If !FFolderInfoArray(TagNumber) = 0 AND !FFolderInfoArray(TagNumber+1) = 0 AND _
             !FFolderInfoArray(TagNumber+2) = 0 AND !FFolderInfoArray(TagNumber+3) = 0 AND WordInserted = False Then
               !FFolderInfoArray(TagNumber) = First inserted byte
               !FFolderInfoArray(TagNumber+1) = First inserted byte
               !FFolderInfoArray(TagNumber+2) = First inserted byte
               !FFolderInfoArray(TagNumber+3) = First inserted byte
           Else
               !FFolderInfoArray(TagNumber) = RawTag(TagNumber)
               !FFolderInfoArray(TagNumber+1) = RawTag(TagNumber+1)
               !FFolderInfoArray(TagNumber+2) = RawTag(TagNumber+2)
               !FFolderInfoArray(TagNumber+3) = RawTag(TagNumber+3)
           End If
        Next TagNumber
        .Refresh
        .MoveNext
    Loop Until .EOF
End With
Random Solutions  
 
programming4us programming4us