Ms Access Runtime Error 2220
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: LoadPicture with jpg files Microsoft Office for Developers > Access for Developers Question 0 Sign in to vote I have an unbound image control on a form. In order to load a picture (a jpg-type picture) into this control, I use the following code: Me.Control.Picture = LoadPicture(“FileNameForPicture”) The above statement triggers the following error: “Run-time Error ‘2220’ Can’t open the file’” The Access documentation for LoadPicture states that the ‘file name’ – the sole argument taken by loadpicture- should be a bitmap file (.bmp), icon file (.ico), run-length encoded file (.rle), or metafile (.wmf). I believe that the above error is due to this - my picture is a jpg one. Additionally, I have double checked the ‘file name’ argument and it is correct. Which statement of code should I use to load my jpg picture into the image control? Image Controls accept jpg pictures: you can assign a picture to a control at design time by setting the picture property. Thanks Wednesday, March 02, 2011 9:04 PM Reply | Quote Answers 0 Sign in to vote Hi JAPA2972, Thank you for posting. If you use the image control in Access 2010, just set the image path to the Picture propety. For instance: Private Sub Form_Load() Dim imgSrc As String imgSrc = "C:\\Users\\v-bpeng\\Desktop\\1.jpg" Me.Image13.Picture = imgSrc End Sub It can load the picture to the image control. I hope it can help you and feel free to follow up after you have tried. Best Regards,Bruce Song [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 2 of 2 Thread: Can't open image in report (Runtime Error 2220) Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 12-03-04,23:32 #1 NeAlvey View Profile View Forum https://social.msdn.microsoft.com/Forums/office/en-US/227fbf55-e878-4f76-81ff-40ecc9591c1b/loadpicture-with-jpg-files?forum=accessdev Posts Registered User Join Date Dec 2004 Posts 5 Unanswered: Can't open image in report (Runtime Error 2220) Hi all, I've done some searching around the forums and found this problem, however everyone seems to figure out the problem and not post it or it is something I'm not dealing with. Anyway, I have an image control in a report and I need to load a http://www.dbforums.com/showthread.php?1070711-Can-t-open-image-in-report-(Runtime-Error-2220) picture based on the record. I'm using this code in the form and it works like a dream: RecipeDir = CurrentDBDir() If IsNull(Picture1.Value) Then strPic1 = RecipeDir & "images\NoPicture.jpg" Else Picture1.SetFocus strPic1 = RecipeDir & "images\" & Picture1.Value End If strRecipe1 = strPic1 imgPicture1.Picture = strPic1 I have my pictures in an "images" directory within the DB directory. This works great within the form, but when I do this in the Report Details "OnPrint", It gives me the Runtime Error 2220: MS Access can't open the file "G:\Recipes\images\NoPicture.jpg" however the picture is out there. Am I missing something? Like I said, it works fine in the form. Thanks all in advance! Last edited by NeAlvey; 12-03-04 at 23:37. Reply With Quote 12-04-04,05:43 #2 healdem View Profile View Forum Posts Jaded Developer Join Date Nov 2004 Location out on a limb Posts 13,692 Provided Answers: 59 I'm not sure but I think "imgPicture1.Picture = strPic1" wont always work. Inserting the code into the 'on print event' is probably to late - should be in the "on format" event. Have you defined a bound image on the report?. Failing that I'd try assigning the image path in the "on
and get tips & solutions from a community of 418,595 IT Pros & Developers. It's quick & easy. Image https://bytes.com/topic/access/answers/691570-image-errors errors P: 62 boliches 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 http://www.pcreview.co.uk/threads/runtime-error-2220.1159819/ 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 ms access for this section is: Expand|Select|Wrap|Line Numbers Message: Res1=InputBox("PleaseenteravalidTicketIDtobeviewedMessage") Text1=Res1 Text1=Format(Text1,">") Text15=Res1 Me.Refresh IfRes1=""ThenExitSub strTicket1="C:\Project1\Tickets\2007-"&Text1&".jpg" strNo1=Me.Text1 Me.imgTicket.Picture=strTicket1 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 IfMe.imgTicket.Picture="(none)"GotoMessage Nothing happens (apart from the 2220 error message) as it is too ms access runtime 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 Post Reply Share this Question 4 Replies Expert 2.5K+ P: 3,532 missinglinq 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
Access Image control & linking the image to that control Using the following code at OnCurrent event: Dim str As String, MyImage As String str = DLookup("SlidePath", "Admin") ' MsgBox str ' MsgBox MyImage If Me![ImagePath] <> "" Then MyImage = Me![ImagePath] Me![Image].Picture = str & MyImage EndIf Now getting Runtime error 2220 Microsoft Access can't open the file 'D:\Test\A102.jpg' msgbox str shows D:\test msgbox MyImage shows \A102.jpg Any suggestions as to what the problem is and how to overcome it would be appreciated TIA Tom Tom, Feb 12, 2005 #1 Advertisements MacDermott Guest An elementary question, perhaps, but do you actually have an image at D:\Test\A102.jpg? Can you open it with another application? "Tom" <> wrote in message news:... > Using Access 2002 have a form with the Access Image control & linking the > image to that control > > Using the following code at OnCurrent event: > > Dim str As String, MyImage As String > > str = DLookup("SlidePath", "Admin") > > ' MsgBox str > ' MsgBox MyImage > If Me![ImagePath] <> "" Then > > MyImage = Me![ImagePath] > Me![Image].Picture = str & MyImage > > EndIf > > Now getting Runtime error 2220 Microsoft Access can't open the file > 'D:\Test\A102.jpg' > > msgbox str shows D:\test > msgbox MyImage shows \A102.jpg > > Any suggestions as to what the problem is and how to overcome it would be > appreciated > > TIA > > Tom > > MacDermott, Feb 13, 2005 #2 Advertisements Tom Guest Thanks for the input - it appears it was some corruption on the form or db as the form was redone in a new db and using the same code and now it works OK. So keeping our fingers crossed... Tom "MacDermott" <> wrote in message news:%... > An elementary question, perhaps, but do you actually have an image at > D:\Test\A102.jpg? > Can you open it with another application? > > "Tom" <> wrote in message > news:... >> Using Access 2002 have a form with the Access Image control & linking the >> image to that control >> >> Using the following code at OnCurrent event: >> >> Dim str As String, MyImage As String >> >> str = DLookup("SlidePath", "Admin") >> >> ' MsgBox str >> ' MsgBox MyImage