LoadPicture Function

Description

The LoadPicture function loads a graphic into an ActiveX control.

Syntax

LoadPicture(stringexpression)

The LoadPicture function has the following argument.

Argument

Description

stringexpression

The file name of the graphic to be loaded. The graphic can be a bitmap file (.bmp), icon file (.ico), run-length encoded file (.rle), or metafile (.wmf).


Remarks

Assign the return value of the LoadPicture function to the Picture property of an ActiveX control to dynamically load a graphic into the control. The following example loads a bitmap into a control called OLECustomControl on an Orders form:

Set Forms!Orders!OLECustomControl.Picture = LoadPicture("Stars.bmp")
The LoadPicture function returns an object of type Picture. You can assign this value to a variable of type Object by using the Set statement.

The Picture object is not a Microsoft Access object, but it is available to procedures in Microsoft Access.

Note You can't use the LoadPicture function to set the Picture property of an image control. This function works with ActiveX controls only. To set the Picture property of an image control, simply assign to it a string specifying the file name and path of the desired graphic.

Example

The following example uses the LoadPicture function to load a metafile into an ActiveX control on an Employees form.

Sub DisplayGraphic()
    Const strConPathToBitmaps = _
        "C:\Program Files\Microsoft Office\Office\Bitmaps\Styles\"

    ' Declare object variables of type Picture and Control.
    Dim objPicture As Object, ctl As Control

    ' Set Control variable to refer to ActiveX control on form.
    Set ctl = Forms!Employees!SomeCustomControl
    ' Assign return value of LoadPicture to Picture object.
    Set objPicture = LoadPicture(strConPathToBitmaps & "Globe.wmf")
    ' Set Picture property of ActiveX control.
    Set ctl.Picture = objPicture
End Sub