Insert File Syntax Help

M

MBoozer

I insert a file (pdf) into a field (LocalScanLink) for 2 reasons. 1 is so
that the user can click on it and bring up the pdf file for viewing. The
second, is that the db application is also for the web and a second field
called (filename) takes the name of the file from LocalScanLink and
concatanates it with a url address so the file is also viewable on the web
since it reads something like (http://www.myaddress.com/water.pdf). The code
I have on the LocalScanLink field afterupdate works well at inserting the
filename into the FileName field, however, it inserts it twice, once with the
name (e.g. water.pdf) and then again as (#water.pdf#) so it looks like this
(water.pdf#water.pdf#). Uuuggghhhh! I imagine this is being caused by the
inserthyperlink command. Does it have to be a hyperlink. Can it be a file
name instead? I really need help on this one as I am syntaxed out and have no
more code ideas. Thanks.

If Len(Me!LocalScanLink & "") > 0 Then
Me!FileName = Me!LocalScanLink
Else
Me!FileName = Null
End If
 
A

Allen Browne

A hyperlink consists of at least 3 parts:
- the display text (before the first #),
- the actual address (between the #s), and
- the subaddress (typically blank, after the 2nd #.)

You can parse out the part you want with the HyperlinkPart() function.

If you don't want that behavior, you could just use a Text field to store
the actual address, and format it to look like a hyperlink (ForeColor blue
and FontUnderline.) Add code to its Click (or DblClick) event to
FollowHyperlink, and yes, you can use that with a Text field.

More info on hyperlink fields in this article:
Introduction to Hyperlink fields
at:
http://allenbrowne.com/casu-09.html
 
M

MBoozer

Thank Allen. I took at look at your recommendations and understand the parse
concept and this is exactly what I need to do. However, I can't get the
syntax correct on the folllowing code:

If Len(Me!LocalScanLink & "") > 0 Then
Me!FileName = Me!LocalScanLink '.HyperlinkPart(acDisplayText)
Else
Me!FileName = Null
End If

Somehow I need to marry the LocalScanLink to the
HyperlinkPart(acDisplayText) BEFORE it goes to Me!FileName. I tried
Me!FileName = Me!LocalScanLink.HyperlinkPart(acDisplayText) and all it is
doing is putting a "1" into the Filename field. I know I'm close and maybe a
little dangerous being a novice and all. Any help is appreciated. Thanks.
 
A

Allen Browne

Is this what you need:
Me!FileName = HyperlinkPart(Me!LocalScanLink, acAddress)
 
M

MBoozer

Thanks a million Allen. I finally figured it out. I got this to work although
my syntax is probably not programmer kosher. I 'll try yours and use your
syntax version. Thanks again for all of your help. This one was eating at me
for 2 days.

Me!FileName = (HyperlinkPart([LocalScanLink], acDisplayText))
 
A

Allen Browne

Yes, worth making the change.
The display text might the the same as the actual address, but it might not.

For example, a hyperlink might contain:
Microsoft Corporate#http://www.microsoft.com#
so it is the address part you want.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

MBoozer said:
Thanks a million Allen. I finally figured it out. I got this to work
although
my syntax is probably not programmer kosher. I 'll try yours and use your
syntax version. Thanks again for all of your help. This one was eating at
me
for 2 days.

Me!FileName = (HyperlinkPart([LocalScanLink], acDisplayText))

Allen Browne said:
Is this what you need:
Me!FileName = HyperlinkPart(Me!LocalScanLink, acAddress)
 
M

MBoozer

Got it Allen. I implemented your syntax. Thanks a mil!

Allen Browne said:
Yes, worth making the change.
The display text might the the same as the actual address, but it might not.

For example, a hyperlink might contain:
Microsoft Corporate#http://www.microsoft.com#
so it is the address part you want.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

MBoozer said:
Thanks a million Allen. I finally figured it out. I got this to work
although
my syntax is probably not programmer kosher. I 'll try yours and use your
syntax version. Thanks again for all of your help. This one was eating at
me
for 2 days.

Me!FileName = (HyperlinkPart([LocalScanLink], acDisplayText))

Allen Browne said:
Is this what you need:
Me!FileName = HyperlinkPart(Me!LocalScanLink, acAddress)


Thank Allen. I took at look at your recommendations and understand the
parse
concept and this is exactly what I need to do. However, I can't get the
syntax correct on the folllowing code:

If Len(Me!LocalScanLink & "") > 0 Then
Me!FileName = Me!LocalScanLink '.HyperlinkPart(acDisplayText)
Else
Me!FileName = Null
End If

Somehow I need to marry the LocalScanLink to the
HyperlinkPart(acDisplayText) BEFORE it goes to Me!FileName. I tried
Me!FileName = Me!LocalScanLink.HyperlinkPart(acDisplayText) and all it
is
doing is putting a "1" into the Filename field. I know I'm close and
maybe
a
little dangerous being a novice and all. Any help is appreciated.
Thanks.

:

A hyperlink consists of at least 3 parts:
- the display text (before the first #),
- the actual address (between the #s), and
- the subaddress (typically blank, after the 2nd #.)

You can parse out the part you want with the HyperlinkPart() function.

If you don't want that behavior, you could just use a Text field to
store
the actual address, and format it to look like a hyperlink (ForeColor
blue
and FontUnderline.) Add code to its Click (or DblClick) event to
FollowHyperlink, and yes, you can use that with a Text field.

More info on hyperlink fields in this article:
Introduction to Hyperlink fields
at:
http://allenbrowne.com/casu-09.html

I insert a file (pdf) into a field (LocalScanLink) for 2 reasons. 1
is
so
that the user can click on it and bring up the pdf file for viewing.
The
second, is that the db application is also for the web and a second
field
called (filename) takes the name of the file from LocalScanLink and
concatanates it with a url address so the file is also viewable on
the
web
since it reads something like (http://www.myaddress.com/water.pdf).
The
code
I have on the LocalScanLink field afterupdate works well at
inserting
the
filename into the FileName field, however, it inserts it twice, once
with
the
name (e.g. water.pdf) and then again as (#water.pdf#) so it looks
like
this
(water.pdf#water.pdf#). Uuuggghhhh! I imagine this is being caused
by
the
inserthyperlink command. Does it have to be a hyperlink. Can it be a
file
name instead? I really need help on this one as I am syntaxed out
and
have
no
more code ideas. Thanks.

If Len(Me!LocalScanLink & "") > 0 Then
Me!FileName = Me!LocalScanLink
Else
Me!FileName = Null
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top