J
John Miller
First of all I am a VBA Cluelss newbie, I admit it, but I think my needs for
VBA code are going to be light.
I am using the following MS Suggested Code (
http://support.microsoft.com/kb/q210100/ ) to display some pictures in a
form based on a table and it works fine. When I try to use the same code to
display pictures in a form based on a query, I keep getting an error "The
value you entered isn't valid for this field." I get it twice, at the end of
a record and at the start of the next record. Can anyone tell me wheat I need
to do to modify this code to work on the query also? BTW, the pictures still
display, I jsut keep getting the error twice per record.
Function setImagePath()
Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String
On Error GoTo PictureNotAvailable
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName
'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))
'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName
'Set ImageFrame to the path of the image file
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "NoPicture.jpg"
Me.ImageFrame.Picture = strImagePath
End Function
VBA code are going to be light.
I am using the following MS Suggested Code (
http://support.microsoft.com/kb/q210100/ ) to display some pictures in a
form based on a table and it works fine. When I try to use the same code to
display pictures in a form based on a query, I keep getting an error "The
value you entered isn't valid for this field." I get it twice, at the end of
a record and at the start of the next record. Can anyone tell me wheat I need
to do to modify this code to work on the query also? BTW, the pictures still
display, I jsut keep getting the error twice per record.
Function setImagePath()
Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String
On Error GoTo PictureNotAvailable
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName
'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))
'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName
'Set ImageFrame to the path of the image file
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "NoPicture.jpg"
Me.ImageFrame.Picture = strImagePath
End Function