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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proble m with loading an image.......

Status
Not open for further replies.

rxg00u

Programmer
Apr 11, 2002
16
0
0
GB
Hi there,
I am creating a form in Access which basically filters through several tables and produces some statistics, now according to these statistics when the user clicks a particular button I would like to load all images from a seperate directory which the user can browse.
I am not asking for the code to do this but i thought using an image object, creating an array of strings (location of images) and some simple programming would allow me to produce something that would achieve my purpose.

I have stumbled at the first hurdle, I thought I would create a temp form so that i can practice on and work on. I have created an image with a default picture and have a single button which on click has the following line
Code:
Image1.Picture = LoadPicture("C:\REDPUMP.JPG")

When the button is clicked a runtime error of 2220 i.e cannot open this file is encountered.
I have no idea what this means as the path is correct and from what i have understood the JPG format is ok to use?

Am i on the wrong track by using the image object or I am just forgetting something simple such as a property on the image etc?

Thanks for your time
Rakesh Garala
 
The syntax is fine, there must be a problem with the location of the image. Image boxes can accept JPG files.

Always better to put an Error Handler into the routine too, to stop runtime errors.

[tt]
Private Sub Command1_Click()
'Initialise Error Handler
On Error GoTo ErrorHandler

'Declare Variables
Dim MyPicture As String
Dim ErrMsg As String

'Set Picture Path and Show
MyPicture = "C:\REDPUMP.JPG"
Image1.Picture = LoadPicture(MyPicture)

'Exit Routine Before ErrorHandler
Exit Sub

ErrorHandler:
'Set Message and Display Box, Then Resume Code
ErrMsg = "The Picture '" & MyPicture & "' Does Not Exist"
MsgBox ErrMsg, vbExclamation, "File Error"

'Resume Code After Error
Resume Next
End Sub
[/tt]

Hope this helps,




jgjge3.gif
[tt]"Very funny, Scotty... Now Beam down my clothes."[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top