Unanswered: VBA Access: Run Time Error '2176': The setting for this propert is too long
There is an access database table called DemoImageT with a field called Image to store images (using OLE Objects). It has another field called ID which is a text field. It has values 1,2,3..etc. I have an Image holder called ImageBox1 in an Access form. When a button is clicked I want to display the image stored in the table in the image holder on the form. I executed a query and stored the results in a recordset. Then I set the picture property to the retrieved image. My code was:
Dim myConnection1 As ADODB.Connection
Dim myRecordSet1 As New ADODB.Recordset
Set myConnection1 = CurrentProject.AccessConnection
Set myRecordSet1.ActiveConnection = myConnection1
myRecordSet1.Open "SELECT * FROM DemoImageT WHERE ID = '1'"
If IsNull(myRecordSet1.Fields(1)) = False Then
MsgBox ("Image present")
ImageBox1.Visible = True
ImageBox1.Picture = myRecordSet1.Fields(1)
MsgBox ("No image")
I get the message box Image present. But then I get:
run time error 2176- The setting for this property is too long.
The error occurs in the line:
Is there something wrong with the code? Is there any other way to retrieve images stored in an Access database using VBA and display it on a form? If the above method is correct, what might be wrong?