Image Picture Attibute must be set?

TriAdX

Registered User.
Local time
Today, 09:24
Joined
Aug 25, 2009
Messages
22
I have a report and form that has multiple images used. The images are pulled from my db. The problem is that now that i have fixed my code so that I can just use the image name instead of the whole path, my initial image.picture attribute is still set to the static path. I want to set it to (none) or something so that it wont error on every image box I use every time I start the form or report. Currently it says it cant find the image. (which i dont even care about that initial image because a new one immediately load from the DB)

Any ideas... I cant even create a new image without it FORCING me to choose an image to use...

Thanks a ton!
Ken
 
Seems like you could do something in an OnCurrent event routine to stop this from happening. Or perhaps, since it is a form issue, OnOpen or OnLoad would also work to define the image control's initial value. On a form, you do the Open event, then the Load event, then Resize, then Activate, then Current.

Once the form window is open, you can jump into the middle of that sequence by doing a corner-drag-n-drop to Resize, or change to another window and then come back to the form for Active. Changing the underlying record (navigating) will do a Current.

Somewhere in one or more of those events, you should be able to do anything you want to that image.
 
it does it in the reports too... in fact.. it does it every time i open the report or form to edit or view.. actually.. it does it even if i just mouse over the report or form name in the create form/report box (where you open the form or report from)
 
So no one has ever used the image.picture attribute dynamically and ran into this issue because they moved files or renamed folders?
 
This is the code I use it basically does a Dir to find the image if it doesn't it sets the Image Control Visible = False. I don't store the images within the database so the Image File is on the Form.

Code:
Function GetPicture()
Dim FullPath As String
    With CodeContextObject
        FullPath = GetImageDir & .[Image File]
        If Dir([FullPath]) <> Empty Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = FullPath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function

GetImagePath is the Full directory where the images are stored.

Simon
 
Simon,

the issue is more that the image control wont let me put an image on my report without defining a picture to use. I dont want to define a picture because there is no "default" picture... every entry uses an image defined in the DB... so the problem is that because I have to define an image before the report is even loaded... it gives me errors because my image path is always changing. (i am constantly moving my project folder and it is on an external drive, so my drive letter is always changing)

In my code the images path is relative to the location of my access file so it works fine there.. but it doesnt work for the first time i load my report.


regarless of all my programming and stuff... you can see my issue by just creating a form... and putting an image control on it.. It FORCES you to choose an image and there is no way to put a wild card or anything else in the path.. and if your project is constantly changing.. then it errors because it cant find it.
 
Why not just create a static image and put it in an accessible path? Something like a white box or something and assign it. I've done that in the past.
 
that doesnt fix the issue when the drive letter changes.

e:\accessprojects\myproject\images\whitebox.jpg
just becomes
f:\accessprojects\myproject\images\whitebox.jpg

and still cant be found...

really.. i just wish there was a way to define no picture to the image.

it even gives me an error when i just mouse over the report in my project.
it errors when i Design Report, Print Preview..

and I have a LOT of images.. so i sit and click ok to the error a ton every time i do anything... this just doesnt make sense why there is no way to set the "default" .picture to null or blank.
 
that doesnt fix the issue when the drive letter changes.

e:\accessprojects\myproject\images\whitebox.jpg
just becomes
f:\accessprojects\myproject\images\whitebox.jpg

and still cant be found...

really.. i just wish there was a way to define no picture to the image.

it even gives me an error when i just mouse over the report in my project.
it errors when i Design Report, Print Preview..

and I have a LOT of images.. so i sit and click ok to the error a ton every time i do anything... this just doesnt make sense why there is no way to set the "default" .picture to null or blank.
Why are you using drive letters and NOT UNC paths? Then it doesn't matter who has what drive letters set.
 
UNC paths?

the drive letter changes because the project is on a removeable HD and i am always using it on different computers.

also, like i said.. sometimes the path changes... becuase of versioning.. and how they do things..

E:\accessprojects\myproject1.1\images\whitebox.jpg
E:\accessprojects\myproject1.2\images\whitebox.jpg

they want different versions saved in completely different folders.. so we can keep all of the project files of each version with its correct version.
 
UNC paths?

the drive letter changes because the project is on a removeable HD and i am always using it on different computers.

also, like i said.. sometimes the path changes... becuase of versioning.. and how they do things..

E:\accessprojects\myproject1.1\images\whitebox.jpg
E:\accessprojects\myproject1.2\images\whitebox.jpg

they want different versions saved in completely different folders.. so we can keep all of the project files of each version with its correct version.

So, you need to store the initial graphic in an accessible location (perhaps a folder on a network drive you all have access to?). It is a pain that the image control needs that, and I have not found a way to put something there but perhaps you can use the form's Error event to cancel the message about it. I don't know as I've always just had the initial image in a location that everyone can access.
 
hmm ok.. well thanks for your insight on it.. anyone have any idea how to use the form's Error event to cancel the message?
 
Ah, instead of setting the initial picture as LINKED, USE EMBEDDED.
 
Yikes... no can do on that one... the file would be HUGE..

even then.. I am 99% sure i Tried that.
 
Yikes... no can do on that one... the file would be HUGE..
NO, I said, create a simple white box and then put that as the embedded image. And then you can assign anything to it later. It just has to be available to the form. So make a 10x10 pixel white box and save it and then select it as the source image. Nobody will see it anyway if you assign the new image in the On Load event of the form. I just tested this and it works great.
 
Changing the image to Embed doesnt embed the images that are called from my DB too?

only the first image selected is embeded?
 
Changing the image to Embed doesnt embed the images that are called from my DB too?

only the first image selected is embeded?

Right, only the initial one which it requires you to have. Having that one embedded ensures that nobody will get that error.
 
Two parts to the solution:

1) Path

Code:
Function GetImageDir() As String
    GetImageDir = e:\accessprojects\myproject\images\
End Function

2) Create an Image 1 x 1 pixel i.e. c:/Wherever_your_database_is/images/blank.jpg

This is your default image basically nothing.

I don't know what circumstances the drive letter changes but the code of GetImageDir is simple to change.

Simon
 
Two parts to the solution:

1) Path

Code:
Function GetImageDir() As String
    GetImageDir = e:\accessprojects\myproject\images\
End Function

2) Create an Image 1 x 1 pixel i.e. c:/Wherever_your_database_is/images/blank.jpg

This is your default image basically nothing.

I don't know what circumstances the drive letter changes but the code of GetImageDir is simple to change.

Simon

Although simpler solution is just to embed the initial image like I said. Then you don't need to make sure the image follows the database around. But yes, that would probably work.
 
Actually, Simon - Your solution is still not the optimal now that I think about it again. The image needs to be set in design view. So, it is whatever path you use in design view, not the database path via code. So, the initial image still would need to be set from the design view (that is the problem with that image control) and if the path is not available when you open, it errors BEFORE anything can be set.

So, embedding is really the ONLY solution here. (I've tested).
 

Users who are viewing this thread

Back
Top Bottom