I have a product database that I have just successfully figured out how to link picture locations which are stored in text fields to image controls in a form. Now I am trying to do the same thing only in a report. If you are interested in how I came to my resolution for my form you can go to this site:
The text fields I am trying to link to are in text fields in a query, which is the control source for the report. The text fields are called Pic1, Pic2, and Pic3. If you notice in my code I have six image controls. The reason I have six controls for 3 pictures has to do with the positioning of the pictures. Not all products will have 3 pictures, so I have to space the pictures out accordingly. When I currently try opening the report, Access cannot find Pic1 (and I'm assuming Pic2 and Pic3), which leads me to the option of debugging. How do I link my Pic directories to my image controls so that they will open properly?
The text fields I am trying to link to are in text fields in a query, which is the control source for the report. The text fields are called Pic1, Pic2, and Pic3. If you notice in my code I have six image controls. The reason I have six controls for 3 pictures has to do with the positioning of the pictures. Not all products will have 3 pictures, so I have to space the pictures out accordingly. When I currently try opening the report, Access cannot find Pic1 (and I'm assuming Pic2 and Pic3), which leads me to the option of debugging. How do I link my Pic directories to my image controls so that they will open properly?
Code:
Private Sub Report_Open(Cancel As Integer)
'Code to link pictures
Dim strPath1 As String
Dim strPath2 As String
Dim strPath3 As String
strPath1 = Nz(Me.Pic1)
strPath2 = Nz(Me.Pic2)
strPath3 = Nz(Me.Pic3)
' Me.Image1A.PICTURE = strPath1
' Me.Image1B.PICTURE = strPath1
' Me.Image1C.PICTURE = strPath1
' Me.Image2A.PICTURE = strPath2
' Me.Image2B.PICTURE = strPath2
' Me.Image3.PICTURE = strPath3
' Me.Image1A.Visible = True
' Me.Image1B.Visible = True
' Me.Image1C.Visible = True
' Me.Image2A.Visible = True
' Me.Image2B.Visible = True
' Me.Image3.Visible = True
If IsNull(Me.Pic1) = False And IsNull(Me.Pic2) = True And IsNull(Me.Pic3) = True Then
Me.Image1A.Visible = True
Me.Image1B.Visible = False
Me.Image1C.Visible = False
Me.Image2A.Visible = False
Me.Image2B.Visible = False
Me.Image3.Visible = False
Me.Image1A.PICTURE = strPath1
ElseIf IsNull(Me.Pic1) = False And IsNull(Me.Pic2) = False And IsNull(Me.Pic3) = True Then
Me.Image1A.Visible = False
Me.Image1B.Visible = True
Me.Image1C.Visible = False
Me.Image2A.Visible = True
Me.Image2B.Visible = False
Me.Image3.Visible = False
Me.Image1B.PICTURE = strPath1
Me.Image2A.PICTURE = strPath2
ElseIf IsNull(Me.Pic1) = False And IsNull(Me.Pic2) = False And IsNull(Me.Pic3) = False Then
Me.Image1A.Visible = False
Me.Image1B.Visible = False
Me.Image1C.Visible = True
Me.Image2A.Visible = False
Me.Image2B.Visible = True
Me.Image3.Visible = True
Me.Image1C.PICTURE = strPath1
Me.Image2B.PICTURE = strPath2
Me.Image3.PICTURE = strPath3
ElseIf IsNull(Me.Pic1) = True And IsNull(Me.Pic2) = True And IsNull(Me.Pic3) = True Then
Me.Image1A.Visible = False
Me.Image1B.Visible = False
Me.Image1C.Visible = False
Me.Image2A.Visible = False
Me.Image2B.Visible = False
Me.Image3.Visible = False
End If
'End Code to link pictures
End Sub