Is it possible to use relative path for images in MS Access 2003 or 2010?
As far as I found out it is not.
You could just play around with generating path during the runtime and make it look like it is a relative path
image1.Picture = <ProgramPath> & "\" & <RelativePath>
but doing it that way, I dont开发者_C百科 have the ability to take a look at the picture during design time. and i do really need that option!
and here is the usecase. if you know a solution, that would be great:
folderDevelopment < only accessable for developers and for playing around with new stuff folderDevelopment\myProgram\myProgramDevelopment.mdb / accdb < testprogram folderDevelopment\myProgram\Images < imagefolder
folderProduction < accessable for normal user
folderProduction\myProgram\Images < imagefolder for the normal user folderProduction\myProgram\myProgramProduction.mdb / accdb < program for regular userat some time i need to copy myProgramDevelopment.mdb, rename it to myProgramProduction.mdb and move it to the other folder.
if i use absolute path, my links dont break but the normal user have no right to read in the folderDevelopment. so images break.
if i use pseudo relative path, the links during runtime are always perfect, but i dont have an image during design time, so its not very nice for development.
only solution I see at the moment is to use absolute paths and change them every time I make the switch (manually or with a macro), which is an option but not very nice.
why access 2003 and even 2010 dont support relative paths? that is so lame :/
Application.CurrentProject.Path
will return the path of the .mdb/.accdb. You can then use that as a base to create a "relative" path.
You cannot directly use relative paths for images in Access 2003 (I can't speak for Access 2010). The generally accepted workaround is to set the image controls Picture
property in the Form_Load event:
Me.MyImg.Picture = Application.CurrentProject.Path & "\images\MyPic.jpg"
精彩评论