Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2014
    Posts
    1

    Post 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)
    Else
    MsgBox ("No image")
    End If
    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:

    Me.ImageBox1.Picture=myRecordSet1.Fields(1)
    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?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    When you work with columns of type Memo or Long Binary, you have to use the GetChunk method to safely retrieve the contents of such a field. See in Access help for details.
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •