I have a form with 2 objects:
Text48 - A text box object which will have either a path to an image file, or a dummy path ("c:\BowlPhotos\Thumbs\tmb.jpg").
Image58 - An Image Object with an empty Picture field that is filled by the VB.
The Text48 value is determined by the value of another text box, generated using an equation that works (so I left it out to avoid confusion).
The intent is to bring up the record and, if a product exists AND an image exists, show the image for that record. Otherwise, show the default "no image" jpg.
I am using the following 2 VB functions:
=============================
Private Sub Form_Current()
On Error Resume Next
If Me.Text48.Value = "c:\BowlPhotos\Thumbs\tmb.jpg" Then
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
Else
If Dir(Me.Text48.Value) Then
Me.Image58.Picture = Me.Text48.Value
Else
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
End If
End If
End Sub
-------------------------------------------
Private Sub Form_Load()
On Error Resume Next
If Me.Text48.Value = "c:\BowlPhotos\Thumbs\tmb.jpg" Then
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
Else
If Dir(Me.Text48.Value) Then
Me.Image58.Picture = Me.Text48.Value
Else
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
End If
End If
End Sub
===============================
There are 3 possible conditions:
1: No product exists. The default text in Text48 is the "NoBowltmb.jpg" path - so the result should show the "NoBowltmb.jpg" image, which it does.
2: A product does exist, and there is an image of it. The text in Text48 is the generated path to that image, and the image does exist - so the result should show the bowl image, which it DOES do.
3: A product does exist, but there is no image of it yet. The text in Text48 is the generated path to that bowl's image, but the image does not yet exist - so the result should show the "NoBowltmb.jpg" image, which it does NOT always do. What it does instead is retain the previous image for the previous record.
Example: If the previous record was for bowl Ash08-021, and the image exists (and was shown for THAT record), the Ash08-021 image shows up in the NEXT record IF there is no image for THAT NEW record. IF, on the other hand, the previous record was also a no image case (and showed the default image), it shows the default NoBowltmb.jpg" image. Of course, if the prior record showed an image from IT'S prior record, that image shows up! Sort of a self replicating error...
Case 3 is the problem - I need it to show either the current selected bowl's image (if it exists) or the default no image (if the image does not exist).
I had hoped that the "Dir" function in the inner If segment would determine if the image existed, and take the appropriate action. It does not seem to do this.
Any ideas?
Text48 - A text box object which will have either a path to an image file, or a dummy path ("c:\BowlPhotos\Thumbs\tmb.jpg").
Image58 - An Image Object with an empty Picture field that is filled by the VB.
The Text48 value is determined by the value of another text box, generated using an equation that works (so I left it out to avoid confusion).
The intent is to bring up the record and, if a product exists AND an image exists, show the image for that record. Otherwise, show the default "no image" jpg.
I am using the following 2 VB functions:
=============================
Private Sub Form_Current()
On Error Resume Next
If Me.Text48.Value = "c:\BowlPhotos\Thumbs\tmb.jpg" Then
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
Else
If Dir(Me.Text48.Value) Then
Me.Image58.Picture = Me.Text48.Value
Else
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
End If
End If
End Sub
-------------------------------------------
Private Sub Form_Load()
On Error Resume Next
If Me.Text48.Value = "c:\BowlPhotos\Thumbs\tmb.jpg" Then
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
Else
If Dir(Me.Text48.Value) Then
Me.Image58.Picture = Me.Text48.Value
Else
Me.Image58.Picture = "C:\BowlPhotos\Thumbs\NoBowltmb.jpg"
End If
End If
End Sub
===============================
There are 3 possible conditions:
1: No product exists. The default text in Text48 is the "NoBowltmb.jpg" path - so the result should show the "NoBowltmb.jpg" image, which it does.
2: A product does exist, and there is an image of it. The text in Text48 is the generated path to that image, and the image does exist - so the result should show the bowl image, which it DOES do.
3: A product does exist, but there is no image of it yet. The text in Text48 is the generated path to that bowl's image, but the image does not yet exist - so the result should show the "NoBowltmb.jpg" image, which it does NOT always do. What it does instead is retain the previous image for the previous record.
Example: If the previous record was for bowl Ash08-021, and the image exists (and was shown for THAT record), the Ash08-021 image shows up in the NEXT record IF there is no image for THAT NEW record. IF, on the other hand, the previous record was also a no image case (and showed the default image), it shows the default NoBowltmb.jpg" image. Of course, if the prior record showed an image from IT'S prior record, that image shows up! Sort of a self replicating error...
Case 3 is the problem - I need it to show either the current selected bowl's image (if it exists) or the default no image (if the image does not exist).
I had hoped that the "Dir" function in the inner If segment would determine if the image existed, and take the appropriate action. It does not seem to do this.
Any ideas?