• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 879
  • Last Modified:

Display Picture from MS Access Control to VB PictureBox

Hello..
I have a problem displaying image in picture box.
The image source  is from MSAccess control image.

Set Picture1.Picture = xImage.Picture   ' This is error!!!!!

Anybody know how to set this picturebox ?
Thanks
'here is a part of my code
'oCtls is Access.Controls
'oCtl is Access.Control
 
        Dim xImage As Access.Image
        For Each oCtl In oCtls
            If TypeOf oCtl Is Access.Image Then
                      Set xImage = oCtl
                      Set Picture1.Picture = xImage.Picture   ' This is error!!!!!
                    End If
        Next oCtl
        Set oCtl = Nothing

Open in new window

0
roundsee
Asked:
roundsee
  • 3
  • 3
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Try using the PictureData property:

Set Picture1.PictureData = xImage.PictureData

How are you actually doing this? Are you automating Access from VB, or are you using a VB control in Access?
0
 
roundseeAuthor Commented:
I can't find PictureData property in PictureBox control.
Here is my code...
Private Sub GetImageInForm(ByVal strFormName As String)
 
        Dim oAccess As Access.Application
        Dim oForm As Access.Form
        Dim oCtls As Access.Controls
        Dim oCtl As Access.Control
        Dim sDBPath As String 'path to Northwind.mdb
        Dim sForm As String 'name of form to show
        Dim xImage As Access.Image
        
        sForm = strFormName
        Set oAccess = New Access.Application
        oAccess.Visible = False
        sDBPath = oAccess.SysCmd(Action:=Access.AcSysCmdAction.acSysCmdAccessDir)
        sDBPath = "C:\Program Files\Microsoft Office\Office12\Samples\Northwind.mdb"
        ' Open Northwind.mdb in shared mode:
        oAccess.OpenCurrentDatabase filepath:=sDBPath, Exclusive:=False
        'Close all openned Form
        For Each oForm In oAccess.Forms
            oAccess.DoCmd.Close ObjectType:=Access.AcObjectType.acForm, _
                ObjectName:=oForm.Name, _
                Save:=Access.AcCloseSave.acSaveNo
        Next
 
        Set oForm = Nothing
        ' Select the form name in the database window and give focus
        ' to the database window:
        oAccess.DoCmd.SelectObject ObjectType:=Access.AcObjectType.acForm, _
            ObjectName:=sForm, InDatabaseWindow:=True
        ' Show the form:
        oAccess.DoCmd.OpenForm FormName:=sForm, View:=Access.AcFormView.acNormal
        Set oForm = oAccess.Forms(sForm)
        Set oCtls = oForm.Controls
        
        For Each oCtl In oCtls
            If TypeOf oCtl Is Access.Image Then
                      Set xImage = oCtl
                      'Trying to display image
                      Set Picture1.Picture = xImage.Picture   ' This is error!!!!!
                      
                    End If
        Next oCtl
        Set oCtl = Nothing
 
        ' Hide the Database Window:
        oAccess.DoCmd.SelectObject ObjectType:=Access.AcObjectType.acForm, _
            ObjectName:=sForm, InDatabaseWindow:=True
        oAccess.RunCommand Command:=Access.AcCommand.acCmdWindowHide
        ' Release Controls and Form objects:
        Set oCtls = Nothing
        Set oForm = Nothing
        ' Release Application object and allow Access to be closed by user:
        If Not oAccess.UserControl Then oAccess.UserControl = True
        Set oAccess = Nothing
        Exit Sub
ErrorCleanup:
        ' Try to quit Access due to an unexpected error:
        On Error Resume Next
        Set oCtl = Nothing
        Set oCtls = Nothing
        Set oForm = Nothing
        Set oAccess = Nothing
        Exit Sub
ErrorHandler:
        MsgBox Err.Number & ": " & Err.Description, _
            MsgBoxStyle.MsgBoxSetForeground, "Error Handler"
        Resume ErrorCleanup
End Sub

Open in new window

0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Did you try:

Set Picture1.Picture = xImage.PictureData
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
roundseeAuthor Commented:
I have tried that
Runt-time error '424':
Object Required
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Sorry ... try it without the Set:

Picture1.Picture = xImage.PictureData
0
 
roundseeAuthor Commented:
Stil error...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now