By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Using a variable to store an jpg

P: n/a
DL
Hi,

Many questions have already been asked and answered about images in
Access... But despite having searched, I have not found an answer to
the following question...

In my DB, several forms display the same 2 jpg images (logos). I do not
want to store the images in the forms themselves as, once in Access,
they increase so much the DB file size.

The alternative is to store them outside and to use the following code
in the on_open event :

Private Sub Form_Open(Cancel As Integer)
Me.Image1.Picture = mypath & myJpg1
Me.Image2.Picture = mypath & myJpg2

This works well but the images are re-loaded everytime the user opens a
form... That slows the process and displays a progress bar.

I though about loading the images into global variables as follows :
(in module)
Dim myImage1 as Variant
Dim myImage2 as Variant

(then, in first form)
myImage1 = mypath & myJpg1
myImage2 = mypath & myJpg2
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

(in all forms)
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

That works as well, but the images are still being reloaded everytime I
open a form...

Is there a way to load the images just once and attach them to controls
when needed ?

Many thanks for any advice,

DL

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
DL
Sorry. Just realized that using the Variant type to store the pictures
was not very useful. Variants can't store images. Stupid mistake !
I then tried to declare the 2 variables as Images... it doesn't work
either. Probably because Images are objects but not "variables"...

Can anyone think about a way to load the images only once, when the
database is open ?

Thanks

DL

DL wrote:
Hi,

Many questions have already been asked and answered about images in
Access... But despite having searched, I have not found an answer to
the following question...

In my DB, several forms display the same 2 jpg images (logos). I do not want to store the images in the forms themselves as, once in Access,
they increase so much the DB file size.

The alternative is to store them outside and to use the following code in the on_open event :

Private Sub Form_Open(Cancel As Integer)
Me.Image1.Picture = mypath & myJpg1
Me.Image2.Picture = mypath & myJpg2

This works well but the images are re-loaded everytime the user opens a form... That slows the process and displays a progress bar.

I though about loading the images into global variables as follows :
(in module)
Dim myImage1 as Variant
Dim myImage2 as Variant

(then, in first form)
myImage1 = mypath & myJpg1
myImage2 = mypath & myJpg2
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

(in all forms)
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

That works as well, but the images are still being reloaded everytime I open a form...

Is there a way to load the images just once and attach them to controls when needed ?

Many thanks for any advice,

DL


Nov 13 '05 #2

P: n/a
"DL" <d.******@pca.be> wrote
In my DB, several forms display the same 2 jpg images (logos). I do not
want to store the images in the forms themselves as, once in Access,
they increase so much the DB file size.

The alternative is to store them outside and to use the following code
in the on_open event :

Private Sub Form_Open(Cancel As Integer)
Me.Image1.Picture = mypath & myJpg1
Me.Image2.Picture = mypath & myJpg2

This works well but the images are re-loaded everytime the user opens a
form... That slows the process and displays a progress bar.

I though about loading the images into global variables as follows :
(in module)
Dim myImage1 as Variant
Dim myImage2 as Variant

(then, in first form)
myImage1 = mypath & myJpg1
myImage2 = mypath & myJpg2
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

(in all forms)
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

That works as well, but the images are still being reloaded everytime I
open a form...


There are several ways to do this, but perhaps you are making this too
complicated. You said that the images are logos, so I assume that they are
small. Have you actually tried to place them where you want and leave them?
Compact the db, try it, compact again, and see if the db has grown in size
unacceptably. As long as you are only using logos on some forms, the issue
may be small.

Second option, open the forms at startup in hidden mode, load the images one
time. When the user opens the form, set visible = True. This will require
some re-coding in several areas, especially if your Open event is doing
anything else that needs to happen every time the form changes, since you
Open event will happen only once per session.

Third option, there is code to change the user's registry settings
(somewhere) to hide the display of hte progress bar. Of course, loading
will still happen, and will still slow your users, they just won't see the
ugly progress bar :).

There are probably other options ...

Darryl Kerkeslager

Nov 13 '05 #3

P: n/a
Open a hidden form containing two Image controls. In that form's Load
event go ahead and load in your two logos. Make sure you have modified
the Registry to not show the Loading Image diaolog.

In the Load event of any form where you want to use the Logo's do
something like:
Me.Image1.PictureData = NameOfHiddenForm.Image1.PictureData
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"DL" <d.******@pca.be> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Sorry. Just realized that using the Variant type to store the pictures
was not very useful. Variants can't store images. Stupid mistake !
I then tried to declare the 2 variables as Images... it doesn't work
either. Probably because Images are objects but not "variables"...

Can anyone think about a way to load the images only once, when the
database is open ?

Thanks

DL

DL wrote:
Hi,

Many questions have already been asked and answered about images in
Access... But despite having searched, I have not found an answer to
the following question...

In my DB, several forms display the same 2 jpg images (logos). I do not
want to store the images in the forms themselves as, once in Access,
they increase so much the DB file size.

The alternative is to store them outside and to use the following

code
in the on_open event :

Private Sub Form_Open(Cancel As Integer)
Me.Image1.Picture = mypath & myJpg1
Me.Image2.Picture = mypath & myJpg2

This works well but the images are re-loaded everytime the user

opens a
form... That slows the process and displays a progress bar.

I though about loading the images into global variables as follows :
(in module)
Dim myImage1 as Variant
Dim myImage2 as Variant

(then, in first form)
myImage1 = mypath & myJpg1
myImage2 = mypath & myJpg2
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

(in all forms)
Me.Image1.Picture = myImage1
Me.Image2.Picture = myImage2

That works as well, but the images are still being reloaded
everytime I
open a form...

Is there a way to load the images just once and attach them to

controls
when needed ?

Many thanks for any advice,

DL


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.