Run-time error '2220'

P

Pierre

I have the following code on my Form_Current property. For some reason I'm
still getting a run time error even though its set to be ignored. Could
someone please take a look at this code and tell me what I am missing.
NOTE: I would also like it to read NONE if there is no information listed in
the field.

Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
If Err.Number = 2220 Then
Me.Image501.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End If
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
If Err.Number = 2220 Then
Me.Image502.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End if
End Sub
 
J

J_Goddard via AccessMonster.com

You need to put an error handler in the procedure. When the error occurs,
Access triggers the run-time error immediately, and does not go to the next
line of code. If error handling has been specified with an On Error...
statement, it does that, otherwise it displays the error message.

Try something like this:

Dim PictureField as Integer
On Error goto Picture_Error

PictureField=501
if not isnull([Per Snapshot]) then
Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
else
Me.Image501.Picture = "(None)"
endif

PictureField=502
if not isnull([Per Home]) then
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
else
Me.Image502.Picture = "(None)"
endif

exit sub

Picture_Error:

If Err.Number = 2220 Then
MsgBox "Check image file name."
if PictureField = 501 then Me.Image501.Picture = "(None)"
if PictureField = 502 then Me.Image502.Picture = "(None)"
resume next
else
msgbox "Error: " & err.description
End if

End Sub

HTH

John


I have the following code on my Form_Current property. For some reason I'm
still getting a run time error even though its set to be ignored. Could
someone please take a look at this code and tell me what I am missing.
NOTE: I would also like it to read NONE if there is no information listed in
the field.

Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
If Err.Number = 2220 Then
Me.Image501.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End If
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
If Err.Number = 2220 Then
Me.Image502.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End if
End Sub
 
P

Pierre

that was so helpful I can't even begin to tell you. there should be a way to
payback all the helpful people on this site.
--
Work is sometimes hard....but someone has to do it.


J_Goddard via AccessMonster.com said:
You need to put an error handler in the procedure. When the error occurs,
Access triggers the run-time error immediately, and does not go to the next
line of code. If error handling has been specified with an On Error...
statement, it does that, otherwise it displays the error message.

Try something like this:

Dim PictureField as Integer
On Error goto Picture_Error

PictureField=501
if not isnull([Per Snapshot]) then
Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
else
Me.Image501.Picture = "(None)"
endif

PictureField=502
if not isnull([Per Home]) then
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
else
Me.Image502.Picture = "(None)"
endif

exit sub

Picture_Error:

If Err.Number = 2220 Then
MsgBox "Check image file name."
if PictureField = 501 then Me.Image501.Picture = "(None)"
if PictureField = 502 then Me.Image502.Picture = "(None)"
resume next
else
msgbox "Error: " & err.description
End if

End Sub

HTH

John


I have the following code on my Form_Current property. For some reason I'm
still getting a run time error even though its set to be ignored. Could
someone please take a look at this code and tell me what I am missing.
NOTE: I would also like it to read NONE if there is no information listed in
the field.

Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
If Err.Number = 2220 Then
Me.Image501.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End If
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
If Err.Number = 2220 Then
Me.Image502.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End if
End Sub
 
P

Pierre

I have an add on question. What could I put in the after update property of
the text field to load the picture.


--
Work is sometimes hard....but someone has to do it.


J_Goddard via AccessMonster.com said:
You need to put an error handler in the procedure. When the error occurs,
Access triggers the run-time error immediately, and does not go to the next
line of code. If error handling has been specified with an On Error...
statement, it does that, otherwise it displays the error message.

Try something like this:

Dim PictureField as Integer
On Error goto Picture_Error

PictureField=501
if not isnull([Per Snapshot]) then
Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
else
Me.Image501.Picture = "(None)"
endif

PictureField=502
if not isnull([Per Home]) then
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
else
Me.Image502.Picture = "(None)"
endif

exit sub

Picture_Error:

If Err.Number = 2220 Then
MsgBox "Check image file name."
if PictureField = 501 then Me.Image501.Picture = "(None)"
if PictureField = 502 then Me.Image502.Picture = "(None)"
resume next
else
msgbox "Error: " & err.description
End if

End Sub

HTH

John


I have the following code on my Form_Current property. For some reason I'm
still getting a run time error even though its set to be ignored. Could
someone please take a look at this code and tell me what I am missing.
NOTE: I would also like it to read NONE if there is no information listed in
the field.

Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
If Err.Number = 2220 Then
Me.Image501.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End If
Me.Image502.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Home]
If Err.Number = 2220 Then
Me.Image502.Picture = "(None)"
Resume Next
Else
MsgBox "Check image file name."
End if
End Sub
 
J

J_Goddard via AccessMonster.com

Hi Pierre -

Thanks for the kind words - they mean a lot.

The After Update procedure would be much the same, except that you would not
need to check which field was causing the error. This would be for [per
snapshot]

Dim PictureField as Integer
On Error goto Picture_Error

if not isnull([Per Snapshot]) then
Me.Image501.Picture = "\\homeserver\home\My Documents\My Pictures\" & [Per
Snapshot]
else
Me.Image501.Picture = "(None)"
endif

exit sub

Picture_Error:

If Err.Number = 2220 Then
MsgBox "Check image file name."
else
msgbox "Error: " & err.description
End if
Resume Next

End Sub

The other would be the same, but you would use [per home] and image502.

John

I have an add on question. What could I put in the after update property of
the text field to load the picture.
You need to put an error handler in the procedure. When the error occurs,
Access triggers the run-time error immediately, and does not go to the next
[quoted text clipped - 64 lines]
 
P

Pierre

You make this seem so easy. But I need your help one more time today.
Expanding more one the image. What would be the Do Command to open Image
Viewer.
i.e. On the image click property. I would like a YES/ON open to open and
view image in Image Viewer. B/c of the Image view size. A user my need to
view it at a larger Scale.
 
J

J_Goddard via AccessMonster.com

I found that the easiest way to do this for me was to make another form, with
just an image control and a close button on, and make the form and image
control as big as I could to fit the screen.

Then, in the On Click event of the smaller image on your form, open the
second form as a popup, and specify the picture to display using the form's
OpenArgs property:

Private Sub Image2_Click()
DoCmd.OpenForm "Form2", , , , , acDialog, Me!Image2.Picture
End Sub

In the On Open procedure of Form2, put this:

Private Sub Form_Open(Cancel As Integer)
Me!Image2.Picture = Me.OpenArgs
End Sub

Set the Picture Type propty of the image controls to Linked.

See if this works for you.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top