title: How to load picture into MS-Access Image control from ADO recordset field?
body: <p>Using: </p>
  
  <ol>
  <li>MS-Access 2013 SP1 x86</li>
  <li>MS-SQL Server 2012 SP1 CU8 x64  </li>
  <li>Connection via ODBC DSN, SQL Server driver</li>
  <li>UpScene Database Workbench Pro v4.4.4 Pro for MS-SQL Server</li>
  </ol>
  
  <p>My Access 2013 application uses SQL Server 2012 as the backend database with ODBC. I'm using VBA/ADO to read/write data to the database.</p>
  
  <p>I have been unsuccessful so far in retrieving an image from the database and assigning it to an image control on an Access form. The image is stored in a SQL Server table (as a VARBINARY(MAX) field. </p>
  
  <p>At the point where I'm assigning the field to the Image control, it gives a runtime error: "Type mismatch". The image stored in the database as a Bitmap image. I tried with Jpeg earlier, but it was the same error. How can this be resolved?</p>
  
  <p>SQL Server table definition and stored procedure definition:</p>
  
  <pre><code>CREATE TABLE dbo.tbPhoto (
      row_id Int IDENTITY NOT NULL,
      student_id Int NOT NULL,
      picture VarBinary(max),
      date_updated DateTime NOT NULL,
      date_created DateTime NOT NULL, 
      CONSTRAINT PK_tbPhoto PRIMARY KEY CLUSTERED (
        row_id
      )
  )
  </code></pre>
  
  <p>Access procedures to retrieve the picture:</p>
  
  <pre><code>Private Sub load_studentdetails(AStudentID As Integer)
   On Error GoTo errhnd
  
   objStudent.GetStudentDetails AStudentID, StudentDetailsRS
  
   Set Me.fmStudentReg_DtlA.Form.Recordset = StudentDetailsRS
  ' Me.fmStudentReg_DtlA.Form.Requery
  
   objStudent.GetStudentPicture AStudentID, Me.fmStudentReg_DtlA!imgStudentPic
  
   Exit Sub
  errhnd:
   MsgBox "Error: " &amp; Err.Description
  End Sub
  
  Public Sub GetStudentPicture(AStudentID As Integer, ByRef APicture As Image)
   On Error GoTo errhnd
  
   Dim rs As New ADODB.Recordset
   Set cmd.ActiveConnection = GetDBConnection
  
   cmd.CommandType = adCmdStoredProc
   cmd.CommandText = "dbo.StudentPicture_S"
  
   cmd.Parameters.Refresh
   cmd(1) = AStudentID
  
   rs.CursorLocation = adUseClient
   rs.Open cmd
  
   Set APicture = rs("picture")  '&lt;-----Raises the error: "Type mismatch"
  
   Exit Sub
  errhnd:
   MsgBox "Error: " &amp; Err.Description
  
  End Sub
  </code></pre>