If 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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Picture on a form: Using a relative path
Hi,
I have an access database for some paintings. On a form I want to show both the image and the details of the painting. The database xx.mdb is in I:\Whatewer\mdb and the images are in I:\Whatever\images. I can accomplish this if I use full path of the images in ImageDir field. However, when I try to use relative path in the ImageDir field I have no luck. I tried the images, \images, .\images notations. The database is in Access 2000 format, but I use it with Access 2002. Thanks for any help, |
#2
|
|||
|
|||
Access doesn't work with relative paths: it will only allow full paths.
Having said that, though, it shouldn't be that difficult to change your paths if you find that they aren't correct, just as you have to change paths for linked tables. A problem is that the Current Directory when you start Access usually isn't the same directory as your MDB is in. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Name" validemail@com wrote in message ... Hi, I have an access database for some paintings. On a form I want to show both the image and the details of the painting. The database xx.mdb is in I:\Whatewer\mdb and the images are in I:\Whatever\images. I can accomplish this if I use full path of the images in ImageDir field. However, when I try to use relative path in the ImageDir field I have no luck. I tried the images, \images, .\images notations. The database is in Access 2000 format, but I use it with Access 2002. Thanks for any help, |
#3
|
|||
|
|||
In testing, I found that Access will accept the relative path in code or you
can type in the relative path. However, once it's been placed in the control, it gets converted to the full path. The control won't save it as a relative path. Me.Image0.Picture = ".\Picture.jpg" or in your case Me.Image0.Picture = "..\Images\Picture.jpg" In your example you only used one dot, which would mean to look in the same directory. You need to use two dots to go up one directory then down to the images directory. -- Wayne Morgan Microsoft Access MVP "Name" validemail@com wrote in message ... Hi, I have an access database for some paintings. On a form I want to show both the image and the details of the painting. The database xx.mdb is in I:\Whatewer\mdb and the images are in I:\Whatever\images. I can accomplish this if I use full path of the images in ImageDir field. However, when I try to use relative path in the ImageDir field I have no luck. I tried the images, \images, .\images notations. The database is in Access 2000 format, but I use it with Access 2002. Thanks for any help, |
#4
|
|||
|
|||
Thanks,
Exponent you are right, I also thought about it after my initial post. Maybe you can help me with a modified solution: Some more detail: The field for the path is "DISK_YERI" and there is also another field named "IMAGE" where the name of the picture is stored: DISK_YERI holds the value: "I:\rsmmdb\xx\image0x.jpg" and the IMAGE holds the value "image0x.jpg. The code for the form is: --------------- Private Sub Form_Current() On Error Resume Next Me![ImagePic].Picture = Me![DISK_YERI] Me!ImagePic.Visible = Len("" & Me![DISK_YERI]) 0 End Sub Private Sub Form_AfterUpdate() On Error Resume Next Me![ImagePic].Picture = Me![DISK_YERI] End Sub ------------------- Now I want to be able to get rid of the field DISK_YERI and use the field IMAGE in the form. I tried to modify the line to match my table but it did not work. Can you modify the code above so that it will work. Thanks, "Exponent" wrote in message news:41382d25$1@lala... The 'current' directory is not necessarily the same each time the application runs, and it can be changed during the lifetime of the application. How about using something like this: Me.Image0.Picture = Application.CurrentProject.Path & "\images\" & "Picture.jpg" -- __________________________________________________ _____ http://www.ammara.com/ Image Handling Components, Samples, Solutions and Info DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous "Name" validemail@com wrote: Hi, I have an access database for some paintings. On a form I want to show both the image and the details of the painting. The database xx.mdb is in I:\Whatewer\mdb and the images are in I:\Whatever\images. I can accomplish this if I use full path of the images in ImageDir field. However, when I try to use relative path in the ImageDir field I have no luck. I tried the images, \images, .\images notations. The database is in Access 2000 format, but I use it with Access 2002. Thanks for any help, |
#5
|
|||
|
|||
Thanks, that did it.
"Exponent" wrote in message news:413c0c0c$1@lala... Assuming that the database is in the folder: I:\rsmmdb\ and *all* the images are in: I:\rsmmdb\xx\ try using the following line in Form_Current(): Me![ImagePic].Picture = Application.CurrentProject.Path & "\xx\" & Me![IMAGE] Watch for line wrap. You could also check that the filename has a valid length, and that the file exists (using the dir command). -- __________________________________________________ _____ http://www.ammara.com/ Image Handling Components, Samples, Solutions and Info DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous "Name" validemail@com wrote: Thanks, Exponent you are right, I also thought about it after my initial post. Maybe you can help me with a modified solution: Some more detail: The field for the path is "DISK_YERI" and there is also another field named "IMAGE" where the name of the picture is stored: DISK_YERI holds the value: "I:\rsmmdb\xx\image0x.jpg" and the IMAGE holds the value "image0x.jpg. The code for the form is: --------------- Private Sub Form_Current() On Error Resume Next Me![ImagePic].Picture = Me![DISK_YERI] Me!ImagePic.Visible = Len("" & Me![DISK_YERI]) 0 End Sub Private Sub Form_AfterUpdate() On Error Resume Next Me![ImagePic].Picture = Me![DISK_YERI] End Sub ------------------- Now I want to be able to get rid of the field DISK_YERI and use the field IMAGE in the form. I tried to modify the line to match my table but it did not work. Can you modify the code above so that it will work. Thanks, "Exponent" wrote in message news:41382d25$1@lala... The 'current' directory is not necessarily the same each time the application runs, and it can be changed during the lifetime of the application. How about using something like this: Me.Image0.Picture = Application.CurrentProject.Path & "\images\" & "Picture.jpg" -- __________________________________________________ _____ http://www.ammara.com/ Image Handling Components, Samples, Solutions and Info DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous "Name" validemail@com wrote: Hi, I have an access database for some paintings. On a form I want to show both the image and the details of the painting. The database xx.mdb is in I:\Whatewer\mdb and the images are in I:\Whatever\images. I can accomplish this if I use full path of the images in ImageDir field. However, when I try to use relative path in the ImageDir field I have no luck. I tried the images, \images, .\images notations. The database is in Access 2000 format, but I use it with Access 2002. Thanks for any help, |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Images in a database | Franz | General Discussion | 10 | October 7th, 2004 09:35 AM |
Upload Image | Jason MacKenzie | General Discussion | 1 | September 1st, 2004 04:38 AM |
Passing value to modal child form in MS Access using VBA? | Grahammer | Using Forms | 6 | July 4th, 2004 11:53 PM |
Recordset in subform based on field in parent form | Lyn | General Discussion | 15 | June 14th, 2004 03:10 PM |
Form Doesn't Go To New Record | Steve | New Users | 15 | May 16th, 2004 04:33 PM |