G
Guest
I am working with Access 2003. I am new to programming and I have a table
with 6 text fields which has paths to images. I want the images to show up
in my report opened. There are 6 image controls(one for each image field)It
is working somewhat, but it seems that when I scoll through the records it
will show the previous image if there is no image to show for that particular
image control. Below is my code. Any suggestions?
Option Compare Database
Option Explicit
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo err_Detail_Format
If Not Me!East_Picture_Before = "" Or Not IsNull(Me!East_Picture_Before)
Then
Me!Picture1.Picture = GetPathPart & Me!East_Picture_Before
Else
Me!Picture1.Picture = ""
End If
If Not Me!East_Picture_After = "" Or Not IsNull(Me!East_Picture_After)
Then
Me!Picture2.Picture = GetPathPart & Me!East_Picture_After
Else
Me!Picture2.Picture = ""
End If
If Not Me!West_Picture_Before = "" Or Not IsNull(Me!West_Picture_Before)
Then
Me!Picture3.Picture = GetPathPart & Me!West_Picture_Before
Else
Me!Picture3.Picture = ""
End If
If Not Me!West_Picture_After = "" Or Not
IsNull(Me!West_Picture_After) Then
Me!Picture4.Picture = GetPathPart & Me!West_Picture_After
Else
Me!Picture4.Picture = ""
End If
If Not Me!Additional_Picture1 = "" Or Not IsNull(Me!Additional_Picture1)
Then
Me!Picture5.Picture = GetPathPart & Me!Additional_Picture1
Else
Me!Picture5.Picture = ""
End If
If Not Me!Additional_Picture2 = "" Or Not IsNull(Me!Additional_Picture2)
Then
Me!Picture6.Picture = GetPathPart & Me!Additional_Picture2
Else
Me!Picture6.Picture = ""
End If
exit_Detail_Format:
Exit Sub
err_Detail_Format:
MsgBox Err.Description
Resume exit_Detail_Format
End Sub
Private Function GetPathPart() As String
' Comments : Returns the path part of a string
' Parameters: strPath - string to parse
' Returns : path part
Dim db As DAO.Database
Dim strPath As String
Dim intCounter As Integer
Set db = CurrentDb
strPath = db.Name
db.Close
Set db = Nothing
For intCounter = Len(strPath) To 1 Step -1
If Mid$(strPath, intCounter, 1) = "\" Then
Exit For
End If
Next intCounter
GetPathPart = Left$(strPath, intCounter)
End Function
with 6 text fields which has paths to images. I want the images to show up
in my report opened. There are 6 image controls(one for each image field)It
is working somewhat, but it seems that when I scoll through the records it
will show the previous image if there is no image to show for that particular
image control. Below is my code. Any suggestions?
Option Compare Database
Option Explicit
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo err_Detail_Format
If Not Me!East_Picture_Before = "" Or Not IsNull(Me!East_Picture_Before)
Then
Me!Picture1.Picture = GetPathPart & Me!East_Picture_Before
Else
Me!Picture1.Picture = ""
End If
If Not Me!East_Picture_After = "" Or Not IsNull(Me!East_Picture_After)
Then
Me!Picture2.Picture = GetPathPart & Me!East_Picture_After
Else
Me!Picture2.Picture = ""
End If
If Not Me!West_Picture_Before = "" Or Not IsNull(Me!West_Picture_Before)
Then
Me!Picture3.Picture = GetPathPart & Me!West_Picture_Before
Else
Me!Picture3.Picture = ""
End If
If Not Me!West_Picture_After = "" Or Not
IsNull(Me!West_Picture_After) Then
Me!Picture4.Picture = GetPathPart & Me!West_Picture_After
Else
Me!Picture4.Picture = ""
End If
If Not Me!Additional_Picture1 = "" Or Not IsNull(Me!Additional_Picture1)
Then
Me!Picture5.Picture = GetPathPart & Me!Additional_Picture1
Else
Me!Picture5.Picture = ""
End If
If Not Me!Additional_Picture2 = "" Or Not IsNull(Me!Additional_Picture2)
Then
Me!Picture6.Picture = GetPathPart & Me!Additional_Picture2
Else
Me!Picture6.Picture = ""
End If
exit_Detail_Format:
Exit Sub
err_Detail_Format:
MsgBox Err.Description
Resume exit_Detail_Format
End Sub
Private Function GetPathPart() As String
' Comments : Returns the path part of a string
' Parameters: strPath - string to parse
' Returns : path part
Dim db As DAO.Database
Dim strPath As String
Dim intCounter As Integer
Set db = CurrentDb
strPath = db.Name
db.Close
Set db = Nothing
For intCounter = Len(strPath) To 1 Step -1
If Mid$(strPath, intCounter, 1) = "\" Then
Exit For
End If
Next intCounter
GetPathPart = Left$(strPath, intCounter)
End Function