Populate ImageList Control Run-Time Error 481 Invalid Picture

Endre

Registered User.
Local time
Today, 19:22
Joined
Jul 16, 2009
Messages
137
Question: Populate ImageList Control Run-Time Error 481 Invalid Picture

I have an application that can connect to any database, and automatically generates a GUI in the style of MSOutlook depending on the tables you have and their interrelations. The GUI shows a tree structure of all data and interconnected tables on the left, detailed form info on the upper right, including a full list on lower right.

In the example of Northwind, I want to assign icons so that specific products or categories, or customers have different icons displayed in the tree structure.

I have an image list that I populate at run time that is linked to my tree. However this list is populated by the function "LoadPicture". I have a form I have created that is linked to a table where Icon links are stored, and I wish to populate from that so that users can maintain their own icon list.

What VBA code do I use to populate from my Table? I can't find any help references to do this. It works successfully using the "LoadPicture" as below, but not from the field bitmap reference in my table.

Dim rst_icn as RecordSet
Set rst_icn = CurrentDb.OpenRecordset("SELECT * FROM tbl_ICN;")

Do While Not rst_icn.EOF
Me.Controls(15).Object.ListImages.Add 1, , LoadPicture("C:\Img1.bmp")
rst_icn.MoveNext
Loop

The following doesn't work where the reference to icn_img is defined as an OLE Object field in my table....

Dim rst_icn as RecordSet
Set rst_icn = CurrentDb.OpenRecordset("SELECT * FROM tbl_ICN;")

Do While Not rst_icn.EOF
Me.Controls(15).Object.ListImages.Add 1, , rst_icn!icn_img
rst_icn.MoveNext
Loop

The first method above is acceptable but clumsy as the users have to also maintain a hyperlink to the image, which I can then read the location of use in the LoadPicture function. However, if the bitmap is already referenced in the table, why can't I reference it without getting the Run-time error 481 Invalid Picture. I have trying setting the link to the bitmap in the table to "linked", but this does not help the code to work although the image is automatically updated when edited from outside Access.


Or is there a better way for users to maintain icons to be used in image lists?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom