Okay--another idea about linking

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hm. If anyone knows the solution to the situation I posed earlier, please let
me know. But here's another workaround that would work (I think).

I have 250 entries, each has a matching picture named primarykey.jpg, (not
that all pictures are actually called primarykey, but that the name of each
graphic is just the primary key) which I want to link to rather than embed,
because that makes it huge.
I have an entry called 50-00104. I want to make a form button I can click on
that will automatically load the picture in the associated graphics program
on the computer. This entry's picture is located at
C:\2004picture\50-00104.jpg . (and the database is in C:\ ) Is that doable?

Thanks
Scott
 
Interesting -
The other post I saw on this topic (very similar) came from a different
poster, and was in a different forum.
If you're multi-posting - posting the same question in separate posts to
different forums - please don't! People in one forum don't know what people
in others are saying. Instead, put all of your newsgroups in the To: (or
Newsgroups:) line of your post. That way the post and all responses go to
all the newsgroups, and anybody looking at the thread sees all of it.

Now, as to your question:
It's not too hard to display an image as you describe:
Put an Image Control on your form.
Whenever you want to display the image for that record (typically in the
form's Current event, or when the path is changed), reset the control's
Picture property.
But your previous post (if it really was yours) suggests that you
already know that, and that the real problem is that you want to display a
different image for each record in a continuous form.
The only way you can display different data for each record in a
continuous form is to have that data bound to an underlying table. As I
think you also indicated, you know that storing images directly in the
database causes a lot of bloat.

One work-around I've seen is to use an alternative design, which puts the
image control in the form header or footer. It displays the picture for
whichever record is selected.
I think I've also heard of 3rd-party controls which could display multiple
images as you request.
(If a Google search doesn't find one, post back and I'll see what I can
dig up.)
Or you could use a report instead of a form...

HTH
 
Hm. If anyone knows the solution to the situation I posed earlier, please
let
me know. But here's another workaround that would work (I think).

I have 250 entries, each has a matching picture named primarykey.jpg, (not
that all pictures are actually called primarykey, but that the name of
each
graphic is just the primary key) which I want to link to rather than
embed,
because that makes it huge.
I have an entry called 50-00104. I want to make a form button I can click
on
that will automatically load the picture in the associated graphics
program
on the computer. This entry's picture is located at
C:\2004picture\50-00104.jpg . (and the database is in C:\ ) Is that
doable?

Yes, what you want is doable..and in fact a good recommend approach.

To launch any file with its associated program (word, excel, etc.), just
use:


application.FollowHyperlink "c:\my documents\test.doc"

The above would open a word doc.

application.FollowHyperlink "c:\2004pictures\50-00104.jpg"

The above would launch the .jpg file as if you double clicked on it....

So, yes...I think you are on the right track...
 
first of all, to answer mac's question, I have not double posted, or posted
this question in another forum. I know that's not nice so I didn't do it. I
did post a similar question in this forum (and twice, by accident), but no
one answered, it was kinda poorly written, etc, so I decided to try again.
Thank you both for your help!

I see what you are saying with
application.FollowHyperlink "c:\2004pictures\50-00104.jpg"
however, my question comes in how can I make the file name relative to the
entry that is currently being displayed. When I'm going through entries
(50-00100, 50-00101, 50-00102, etc) I need to click a button labeled "Show
Picture" and have each's respective picture pop up. Wouldn't the above line
of code just make 50-00104's picture come up no matter what entry was active
in the form when I clicked the button? Thanks for your help!

Scott
 
Scott -

You're right, hardcoding the number "50-00104" would make that picture pop
up no matter what. What you're talking about doing is concantenating a
string out of constants and variables. I've had to build relative pathnames
into my program because I never know where my users will install my programs.

Use the FollowHyperlink command, but instead of

"c:\2004pictures\50-00104.jpg"

for the pathname, use

"c:\2004pictures\" & me.primarykey & ".jpg"

Me.primarykey is a reference to the control bound to the entry number. If
your form doen't display the control already, you will need to add a control
that holds this value. (it can be invisible if you don't want your users to
see it, but it has to exist). If the 50 and the 00104 are different fields,
you can follow the same concept and concantenate

"c:\2004pictures\" & me.key1 & "-" & me.key2 & ".jpg"

Access will then use the values supplied by the form from the records to
create the filepath each time the button is pressed.

Also as a side note - I would look into putting code in the form's current
event to check and see if the picture for that record exists, and disable the
button if it doesn't. That way your users don't run into the frustrating
problem of clicking on the button, expecting to see a picture, and, if
something has happened to the file, getting an error message from whatever
program they use to open picture files. Unfortunately, the command for
checking to see if a file exists escapes me at the moment... but I know there
IS one!

Happy Programming!

Amanda
 
I got it!

Application.FollowHyperlink "c:\2004pictures\" + Me.[Child Number] + ".jpg"

was what I was looking for, for anyone concerned. Thanks a bunch for the help!
 
Did you also see the link I posted on the other question?

I got it!

Application.FollowHyperlink "c:\2004pictures\" + Me.[Child Number] + ".jpg"

was what I was looking for, for anyone concerned. Thanks a bunch for the help!


Scott said:
first of all, to answer mac's question, I have not double posted, or posted
this question in another forum. I know that's not nice so I didn't do it. I
did post a similar question in this forum (and twice, by accident), but no
one answered, it was kinda poorly written, etc, so I decided to try again.
Thank you both for your help!

I see what you are saying with
application.FollowHyperlink "c:\2004pictures\50-00104.jpg"
however, my question comes in how can I make the file name relative to the
entry that is currently being displayed. When I'm going through entries
(50-00100, 50-00101, 50-00102, etc) I need to click a button labeled "Show
Picture" and have each's respective picture pop up. Wouldn't the above line
of code just make 50-00104's picture come up no matter what entry was active
in the form when I clicked the button? Thanks for your help!

Scott
 
Back
Top