Displaying Multiple Images with .SourceDoc

fomar

New member
Local time
Today, 04:54
Joined
Dec 21, 2006
Messages
5
Hi,

I am new to Access forms and need some help. I did some research and figured out to display images in Acess Forms while getting the image path from a text field in the table. The images are suppose to change for each record. I have no problem displaying the first image a different image for each record but I am having problems displaying the second image. I have to 2 different fields for both image paths in the table. Here is the code:

Private Sub Form_Current()
On Error Resume Next
If Not IsNull(Me![Image1]) Then
Me![ImageFrame1].OLETypeAllowed = 1
Me![ImageFrame1].SourceDoc = Me![Image1]
Me![ImageFrame1].Action = 0
Else
Me![ImageFrame].SourceDoc = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\no-image.bmp"
Me![ImageFrame].Action = 0
End If

If Not IsNull(Me![Image2]) Then
Me![ImageFrame2].OLETypeAllowed = 1
Me![ImageFrame2].SourceDoc = Me![Image2]
Me![ImageFrame2].Action = 0
Else
Me![ImageFrame2].SourceDoc = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\no-image.bmp"
Me![ImageFrame2].Action = 0
End If
End Sub

The problem is that the function returns after 'Me![ImageFrame].Action = 0' and doesn't go to the part where I am checking if the 2nd image exists. If I take out 'Me![ImageFrame].Action = 0' then it doesn't display the first image and goes on the 2nd image and displays the 2nd image.
So that he bottom line is, with this code I can only display one image (either f1st or 2nd). Also, I tried using .Picture property instead of .SourceDoc but that doesn't work either. How can I change this so that I can display both images?

I really need to figure this out and will really appreicate any help. Thank you
 
My read in Access help, having searched "Action Property" indicates that by setting this property = zero you attempt to create a new object of the type specified. If this is a bitmap, the software that your system deems to be a bitmap editor attempts to create a new document in the control, fails without a VBA error and gives your current result.
I don't have experience doing what you are trying here, but maybe set the Action property to 1, which is acOLECreateLink, which links the control to an existing file.
Better yet, search Access help on "Action Property". There are other actions that may yield more desireable results.
 

Users who are viewing this thread

Back
Top Bottom