473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Image errors

I am trying to work around a problem where I can avoid the following message:

"Runtime error 2220

Cannot open file "C:\Project1\Tickets\2007-04BP1006.jpg" etc.

This occurs when I try to load a file that does not exist, the rest of the script seems to work fine. I have used error traps but this one escapes. my code for this section is:
Expand|Select|Wrap|Line Numbers
  1.  Message:
  2. Res1 = InputBox("Please enter a valid Ticket ID to be viewed Message")
  3. Text1 = Res1
  4. Text1 = Format(Text1, ">")
  5. Text15 = Res1
  6. Me.Refresh
  7. If Res1 = "" Then Exit Sub
  8. strTicket1 = "C:\Project1\Tickets\2007-" & Text1 & ".jpg"
  9. strNo1 = Me.Text1
  10. Me.imgTicket.Picture = strTicket1
  11.  
  12.  
I want to be able to reintroduce the InputBox when Me.imgTicket.Picture = "(none)", anyone have any ideas on how I can acieve this, as currently if I put:

Expand|Select|Wrap|Line Numbers
  1.  If Me.imgTicket.Picture ="(none)" Goto Message
Nothing happens (apart from the 2220 error message) as it is too late to catch the error! its already happened ie

strTicket=C:\Project1\Tickets\2007-04BP1006.jpg
if this image does not exist then
Me.imgTicket.Picture=("none")

Hopes this makes some sense to someone.

Thanks
Aug 12 '07 #1
4 4825
missinglinq
3,532 Expert 2GB
You have inadvertently posted your question in the Articles section rather than in the Forum section of our site, so I have moved it across to te Forum for you.

While single lines of code don't necessarily require the use of Code Tags, all code posted consisting of 2 or more lines does.

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

When posting VBA code, please tag it specifically as VBA code. It's really simple; after hi-liting the code and clicking on the # icon, go to the opening code tag and change code to code=vbl . Just like that, with no spaces between code = or vb.

Doing this allows the editor to color code various components in theVBA code , making it much easier for everyone to read! I've gone ahead and re-tagged this one for you.

Thank you!

Linq ;0)>
Aug 12 '07 #2
ADezii
8,834 Expert 8TB
I am trying to work around a problem where I can avoid the following message:

"Runtime error 2220

Cannot open file "C:\Project1\Tickets\2007-04BP1006.jpg" etc.

This occurs when I try to load a file that does not exist, the rest of the script seems to work fine. I have used error traps but this one escapes. my code for this section is:
Expand|Select|Wrap|Line Numbers
  1.  Message:
  2. Res1 = InputBox("Please enter a valid Ticket ID to be viewed Message")
  3. Text1 = Res1
  4. Text1 = Format(Text1, ">")
  5. Text15 = Res1
  6. Me.Refresh
  7. If Res1 = "" Then Exit Sub
  8. strTicket1 = "C:\Project1\Tickets\2007-" & Text1 & ".jpg"
  9. strNo1 = Me.Text1
  10. Me.imgTicket.Picture = strTicket1
  11.  
  12.  
I want to be able to reintroduce the InputBox when Me.imgTicket.Picture = "(none)", anyone have any ideas on how I can acieve this, as currently if I put:

Expand|Select|Wrap|Line Numbers
  1.  If Me.imgTicket.Picture ="(none)" Goto Message
Nothing happens (apart from the 2220 error message) as it is too late to catch the error! its already happened ie

strTicket=C:\Project1\Tickets\2007-04BP1006.jpg
if this image does not exist then
Me.imgTicket.Picture=("none")

Hopes this makes some sense to someone.

Thanks
Before loading a File into an Image Control, always make sure the Path is correct and the File does exist, as in:
Expand|Select|Wrap|Line Numbers
  1. Dim strPathToImage As String
  2.  
  3. strPathToImage = "C:\Test\Chair.jpg"
  4.  
  5. If Dir(strPathToImage, vbNormal) <> "" Then
  6.   Me![imgTest].Picture = strPathToImage
  7. Else
  8.   MsgBox "Path to File does not exist or File Name incorrect!", vbExclamation, "Invalid File Name"
  9. End If
Aug 12 '07 #3
You guys are fantastic!

Many thanks.
Aug 12 '07 #4
ADezii
8,834 Expert 8TB
You guys are fantastic!

Many thanks.
Always glad to help!
Aug 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: Wonko | last post by:
Here's my problem if anyone could be so kind to help me out. I assume it's quite easy for an experienced programmer but I'm not one of them :) I have a JavaScript code that: - displays multiple...
0
by: Greg Christie | last post by:
I think I have a somewhat unique situation here, so I thought I should post it for the few poor souls who run across it and try to google it like I did. First of all, I was getting the following...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
0
by: mhospodarsky | last post by:
Hi-- I am using VB.Net 2002 for this app. I am working with Tiff and jpeg images. I have a picturebox set up that I use to view the images. I have the picture box inside of a scrollable...
4
by: NASAdude | last post by:
I'm working on distributing a database using VS Tools for Office, and am having trouble with linked images on forms/reports. The image objects have a default path\file set on the .Picture property,...
6
by: JezB | last post by:
I have an Image object (i) which I want to write to a file. This does work but when I later try to do something with this file I get errors, because I think the file is still 'locked'. I have to...
2
by: Tarik Monem | last post by:
OK! I've gone through a few tutorials and I cannot understand what I'm doing wrong casting_registration.php <table> <tr> <td> <form enctype="multipart/form-data" action="thankyou.php"...
2
by: mac | last post by:
Hi, I'm looking for a script that will allow me to upload images to a folder and shows pagination... pls can any body help me? i hav done with the uploading, but not able to do with the...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.