Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture Linking Form Missing JPG File and Display the previous JPG

Status
Not open for further replies.

2manyerrors

Programmer
May 14, 2009
36
US
Hi, I'm trying to make this code work on my form but can't seem to get it working. I hope someone can help. Thanks a head of time.

I have a form that links to some picture files and displays the picture in a box. The form works fine except for when the picture is missing or when it is deleted then the picture that was displayed in the prior record is used. I'm trying get the form to display a default image from my c drive such as C:\noimage.jpg if there is no picture or if the picture have been deleted. This way the user will know that the picture does not exist.

Here are my codes for the on current and on load:


--ON CURRENT--
Private Sub Form_Current()
On Error GoTo err_Form_Current

If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
Me!Picture.Picture = Me!txtPicture
Else
Me!Picture.Picture = ""
End If

exit_Form_Current:
Exit Sub

err_Form_Current:
MsgBox err.Description
Resume exit_Form_Current
End Sub

---ON OPEN---
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

If IsNull(Me!txtPicture) Or Me!txtPicture = "" Then
' do nothing
Else
Me!Picture.Picture = Me!txtPicture
End If

Exit_Form_Open:
Exit Sub

Err_Form_Open:
MsgBox err.Description
Resume Exit_Form_Open

End Sub
 
Replace this:
If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
with this:
If Not Me!txtPicture = "" [!]And[/!] Not IsNull(Me!txtPicture) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I think I have it working some what but something unexpected came up.

I changed the codes to:
--------------------------------
Private Sub Form_Current()
On Error GoTo err_Form_Current

If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
Me!Picture.Picture = Me!txtPicture
Else
Me!Picture.Picture = "C:\noimage.jpg"
End If

exit_Form_Current:
Exit Sub

err_Form_Current:
Me!Picture.Picture = "C:\noimage.jpg"
'MsgBox err.Description
Resume exit_Form_Current
End Sub
--------------------------------
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

If IsNull(Me!txtPicture) Or Me!txtPicture = "" Then
Me!Picture.Picture = "C:\noimage.jpg"
Else
Me!Picture.Picture = Me!txtPicture
End If

Exit_Form_Open:
Exit Sub

Err_Form_Open:
Me!Picture.Picture = "C:\noimage.jpg"
'MsgBox err.Description
Resume Exit_Form_Open

End Sub
--------------------------------


This seems to do what I need but there is a problem.
When I use the navigational arrows and "quickly" click to go back and forth through the records. There is a stuck window on my screen.
The stuck window says: Importing: c:\document\picture\image003.jpg
with the cancel button on the bottom of the dialog box. When I try to click the cancel button, nothing happens. The loading bar in the window just sits at half way. I can still click on the form and etc. but this little box is just stuck on the screen on top of all my other forms and reports. To get rid of it, I have to exit out of Access. There is no x on the window.

Any ideas?

Using Access 2003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top