Strip Hyperlink Code on Field Populate

G

Guest

I am trying to access automatcially insert a filename from a hyperlink field.
I have a control on my form (MSDSDocs) that is called LocalScanLink. It works
great! I also have a field called FileName on the same form. When the user
clicks on the LocalScanLink, it automatically inserts the user selected file,
usually a pdf file. However, the user then has to "manually" type in the name
of the file into the FileName field. I automated this so that the file name
and its extension (e.g. water.pdf), are automatically populated into the
filename field. However, what i get is this "MSDS.pdf#MSDS.pdf#"

I want just the "MSDS.pdf" part with no hyperlink (not the #MSDS.pdf#
part)formatting but still need to keep the LocalScanLink as a hyperlink.
Anyway to strip some of the info before the FileName field is populated? The
code on my LocalScanLink control is:

Me.LocalScanLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
'Command to insert hyperlink path to scanned MSDS image
If Len(Me!LocalScanLink & "") > 0 Then
Me!FileName = Me!LocalScanLink
Else
Me!FileName = Null
End If
'Code to insert LocalScankLink filename into FileName field
 
J

John Nurick

Try something like

Dim strFileName As String
Dim lngPos As Long

....
If Len(Me!LocalScanLink & "") > 0 Then
strFileName = Me!LocalScanLink
lngPos = Instr(strFileName, "#")
If LngPos > 0 Then
strFileName = Left(stFileName, lngPos - 1)
End If
Me!FileName = strFileName
Else
...
 
G

Guest

Thanks John. I still can't get it to work. I am unsure on control I shoudl
put it on:
Form
LocalScanLink
FileName
and then on what event (oncurrent, etc.). Any ideas? Thank you.
 

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