Hyperlink issues

G

Guest

I have an application with Hyperlink field in a form. When the user double
clicks on the field, I use the following code to bring up the insert
Hyperlink Dialog Box.

Private Sub Support_DblClick(Cancel As Integer)
On Error GoTo Err_Support_DblClick

DoCmd.RunCommand acCmdInsertHyperlink
Exit_Support_DblClick:

Exit Sub

Err_Support_DblClick:
Resume Exit_Support_DblClick
End Sub

A couple questions... is there a way I can have the dialog box open to a
specific directory instead of the current directory?

Lastly ( and more importantly) for some reason, when certain users use this
feture, the link gets stored in the following form: ..\..\..\charge through
copies of bills\November 15\1-Katten-Mercer Staffing.pdf

I don't know why it does this instead of the full path name. The problem is
that ( I think) the Front End is stored on each users' computer and I'm
guessing the ..\..\.. means something different depending on the computer
it's being clicked on??? Either way, when it saves the hyperlinks like that,
they don't always work.

Ideas?
 
G

Guest

Hmmm,

Ok, sounds good but how would I actually go about do it? This kind (and
most kinds) of code is a little beyond me.
 
G

Guest

Copy yhe code from the site and paste in a new module, then change
DoCmd.RunCommand acCmdInsertHyperlink to

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Tiff Files (*.tif)", "*.TIF") 'this
is an example you can add as many file extensions or types as you want or
just leave the all files

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please Select file to Attach...", _
Flags:=ahtOFN_HIDEREADONLY, _
InitialDir:="C:\temp", hwnd:=Me.hwnd)

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

This is a little rough, but it does the job. I use the variables a and z to
show a name instead of the full path. I made some changes on the fly here,
so I could have a typo.
 
G

Guest

Ok,

I think I almost hve this working. I got a compile error on:

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

It doesn't like the strFilter unless I put quotes around it.

Also, if the user open the dialogbox but then cancels, how can I get the the
code to clear the Support field. As it stands, it saves a partial link.


schasteen said:
Copy yhe code from the site and paste in a new module, then change
DoCmd.RunCommand acCmdInsertHyperlink to

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Tiff Files (*.tif)", "*.TIF") 'this
is an example you can add as many file extensions or types as you want or
just leave the all files

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please Select file to Attach...", _
Flags:=ahtOFN_HIDEREADONLY, _
InitialDir:="C:\temp", hwnd:=Me.hwnd)

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

This is a little rough, but it does the job. I use the variables a and z to
show a name instead of the full path. I made some changes on the fly here,
so I could have a typo.

Bdavis said:
Hmmm,

Ok, sounds good but how would I actually go about do it? This kind (and
most kinds) of code is a little beyond me.
 
G

Guest

Replace

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
Else
Me!support = null
End If

with

If Not strInputFileName = "" Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

Hopefully this will give you the desired result. Unsure why the quote were
needed, did you declare strFilter as a string value? Here is how I declared
the variables:
Dim strFilter As String
Dim strInputFileName As String
Dim varFileName As String
Dim a As String
Dim z As String

Bdavis said:
Ok,

I think I almost hve this working. I got a compile error on:

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

It doesn't like the strFilter unless I put quotes around it.

Also, if the user open the dialogbox but then cancels, how can I get the the
code to clear the Support field. As it stands, it saves a partial link.


schasteen said:
Copy yhe code from the site and paste in a new module, then change
DoCmd.RunCommand acCmdInsertHyperlink to

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Tiff Files (*.tif)", "*.TIF") 'this
is an example you can add as many file extensions or types as you want or
just leave the all files

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please Select file to Attach...", _
Flags:=ahtOFN_HIDEREADONLY, _
InitialDir:="C:\temp", hwnd:=Me.hwnd)

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

This is a little rough, but it does the job. I use the variables a and z to
show a name instead of the full path. I made some changes on the fly here,
so I could have a typo.

Bdavis said:
Hmmm,

Ok, sounds good but how would I actually go about do it? This kind (and
most kinds) of code is a little beyond me.

:

Look at
http://www.mvps.org/access/api/api0001.htm
This is a great tool. You can get the path to set your hyperlink to and set
a default location to begin the search in. The only tricky part may be if
users have different drive letters for network locations, in which case you
can modify the code from
http://www.mvps.org/access/api/api0003.htm
to remove the drive letter. This website has a lot of good code and examples.

:

I have an application with Hyperlink field in a form. When the user double
clicks on the field, I use the following code to bring up the insert
Hyperlink Dialog Box.

Private Sub Support_DblClick(Cancel As Integer)
On Error GoTo Err_Support_DblClick

DoCmd.RunCommand acCmdInsertHyperlink
Exit_Support_DblClick:

Exit Sub

Err_Support_DblClick:
Resume Exit_Support_DblClick
End Sub

A couple questions... is there a way I can have the dialog box open to a
specific directory instead of the current directory?

Lastly ( and more importantly) for some reason, when certain users use this
feture, the link gets stored in the following form: ..\..\..\charge through
copies of bills\November 15\1-Katten-Mercer Staffing.pdf

I don't know why it does this instead of the full path name. The problem is
that ( I think) the Front End is stored on each users' computer and I'm
guessing the ..\..\.. means something different depending on the computer
it's being clicked on??? Either way, when it saves the hyperlinks like that,
they don't always work.

Ideas?
 
G

Guest

Perfect! Thanks.

schasteen said:
Replace

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
Else
Me!support = null
End If

with

If Not strInputFileName = "" Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

Hopefully this will give you the desired result. Unsure why the quote were
needed, did you declare strFilter as a string value? Here is how I declared
the variables:
Dim strFilter As String
Dim strInputFileName As String
Dim varFileName As String
Dim a As String
Dim z As String

Bdavis said:
Ok,

I think I almost hve this working. I got a compile error on:

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

It doesn't like the strFilter unless I put quotes around it.

Also, if the user open the dialogbox but then cancels, how can I get the the
code to clear the Support field. As it stands, it saves a partial link.


schasteen said:
Copy yhe code from the site and paste in a new module, then change
DoCmd.RunCommand acCmdInsertHyperlink to

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Tiff Files (*.tif)", "*.TIF") 'this
is an example you can add as many file extensions or types as you want or
just leave the all files

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please Select file to Attach...", _
Flags:=ahtOFN_HIDEREADONLY, _
InitialDir:="C:\temp", hwnd:=Me.hwnd)

If Not IsNull(strInputFileName) Then
a = Right(strInputFileName, Len(strInputFileName) -
InStrRev(strInputFileName, "\"))
z = strInputFileName
If Left(z, 1) = "\" Then
Me![support] = a & "#" & z
Else

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(Left(z,
1))))
z = d.ShareName & "\" & Right(strInputFileName,
Len(strInputFileName) - InStr(strInputFileName, "\"))
Me![support] = a & "#" & z
End If
End If

This is a little rough, but it does the job. I use the variables a and z to
show a name instead of the full path. I made some changes on the fly here,
so I could have a typo.

:

Hmmm,

Ok, sounds good but how would I actually go about do it? This kind (and
most kinds) of code is a little beyond me.

:

Look at
http://www.mvps.org/access/api/api0001.htm
This is a great tool. You can get the path to set your hyperlink to and set
a default location to begin the search in. The only tricky part may be if
users have different drive letters for network locations, in which case you
can modify the code from
http://www.mvps.org/access/api/api0003.htm
to remove the drive letter. This website has a lot of good code and examples.

:

I have an application with Hyperlink field in a form. When the user double
clicks on the field, I use the following code to bring up the insert
Hyperlink Dialog Box.

Private Sub Support_DblClick(Cancel As Integer)
On Error GoTo Err_Support_DblClick

DoCmd.RunCommand acCmdInsertHyperlink
Exit_Support_DblClick:

Exit Sub

Err_Support_DblClick:
Resume Exit_Support_DblClick
End Sub

A couple questions... is there a way I can have the dialog box open to a
specific directory instead of the current directory?

Lastly ( and more importantly) for some reason, when certain users use this
feture, the link gets stored in the following form: ..\..\..\charge through
copies of bills\November 15\1-Katten-Mercer Staffing.pdf

I don't know why it does this instead of the full path name. The problem is
that ( I think) the Front End is stored on each users' computer and I'm
guessing the ..\..\.. means something different depending on the computer
it's being clicked on??? Either way, when it saves the hyperlinks like that,
they don't always work.

Ideas?
 

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