Need Code for Error Message

S

Stockwell43

Hello,

I created a logo for my database in photoshop and placed it in my form
using: Insert, picture and then locate the picture in my directory and then
inserted it. Looks good on the form however, when a user opens the form they
get this error message: Error Number 438 Object doesn't support this property
or method. I saved the pic as a Gif and Jpeg and still does it.

I do have some security code that if you only have read only access, you get
this message. If you have full access, you do not get this message. The code
is not mine but I would think there should be some code to stop the message
from appearing. If not, all the user has to do is click ok and it goes away
but I'd rather not have it show at all.

Thank you!!
 
B

Bob Bonta

Recommend putting some error trapping in the form load, capture the
err.number, and resume next when that err.number is encountered.
 
S

Stockwell43

Hi Bob, thanks for your reply.

I am not a hundred percent with coding. Do you know what code I would use to
trap this error?

Thanks!!
 
B

Bob Bonta

The first thing you need to do is test this and trap the specific error code
for the problem related to the object. You don't necessarily want to
arbitrarily just proceed to load the form regardless of the error encountered.

So ... these instructions are in two-part. Part one is to learn the error
number, while part two will be to handle that error number exlusively while
alerting the user of any other errors encountered.

'-----------------------------------------------------------------------------------------------
'Part One: copy paste this code in your Form_load event
'-----------------------------------------------------------------------------------------------

Sub Form_Load()
on error goto Error_Loading_Form

Exit_Sub:
exit sub

Error_Loading_Form:
msgbox "Err#: " & err.number & vbcrlf & "Err Description: " &
err.description
'Take note of the err# and err description when the message box pops up ...
resume Exit_Sub

end sub
'-----------------------------------------------------------------------------------------------

'---------------------------------------------------------------------------------------------------
'Part Two: copy paste this code in your Form_load event,
' replacing its current contents
'---------------------------------------------------------------------------------------------------

Sub Form_Load()
on error goto Error_Loading_Form

Exit_Sub:
exit sub

Error_Loading_Form:
Select Case err.number
case ### 'enter the err.number from Part One

case else
msgbox "Err#: " & err.number & vbcrlf & "Err Description: " &
err.description
resume Exit_Sub
End Select

End sub

Hope that helps ...
 
B

Bob Bonta

Sorry ... (don't like this small box in which to write things out). I left
something out in the Case statement (in Part Two) submitted ... see below ...
 
S

Stockwell43

Hi Bob,

This line of code is giving me a complie error and is highlighted in red:
msgbox "438: " & err.number & vbcrlf & "Err Description: " &

Is there something else I was supopose to do with it?

Everything else seems to be normal.

Thanks!
 
S

Stockwell43

The Compile Error says: "Expected Expression"

Bob Bonta said:
Sorry ... (don't like this small box in which to write things out). I left
something out in the Case statement (in Part Two) submitted ... see below ...
 

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