Hyperlink

  • Thread starter Thread starter Kathy Webster
  • Start date Start date
K

Kathy Webster

Creating a field that is a hyperlink in a form is difficult for the user to
edit.
I would therefore like to make the field a normal text field, then put a
control button next to that field that will execute the hyperlink.

For example, [WordProcessingFolder] is the field name. The user types C:\WP
in the field.
When they click on this control button, the cursor opens Windows Explorer to
the C:\WP folder.

Any suggestions? I would much rather just make the field
[WordProcessingFolder] a hyperlink field. But it is too hard for an end user
to edit the contents of that field.
 
Hi Kathy,

Use Application.FollowHyperlink.

Creating a field that is a hyperlink in a form is difficult for the user to
edit.
I would therefore like to make the field a normal text field, then put a
control button next to that field that will execute the hyperlink.

For example, [WordProcessingFolder] is the field name. The user types C:\WP
in the field.
When they click on this control button, the cursor opens Windows Explorer to
the C:\WP folder.

Any suggestions? I would much rather just make the field
[WordProcessingFolder] a hyperlink field. But it is too hard for an end user
to edit the contents of that field.
 
Sorry, I can't find any examples of how that would work in my situation.
Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do not want
to make it a hyperlink field. I want a command button next to the field,
that when you click it, it will open Windows Explorer and go to the folder
named in the [WPFolder] field.

Thanks,
Kathy

John Nurick said:
Hi Kathy,

Use Application.FollowHyperlink.

Creating a field that is a hyperlink in a form is difficult for the user
to
edit.
I would therefore like to make the field a normal text field, then put a
control button next to that field that will execute the hyperlink.

For example, [WordProcessingFolder] is the field name. The user types
C:\WP
in the field.
When they click on this control button, the cursor opens Windows Explorer
to
the C:\WP folder.

Any suggestions? I would much rather just make the field
[WordProcessingFolder] a hyperlink field. But it is too hard for an end
user
to edit the contents of that field.
 
Kathy said:
Sorry, I can't find any examples of how that would work in my
situation. Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do
not want to make it a hyperlink field. I want a command button next
to the field, that when you click it, it will open Windows Explorer
and go to the folder named in the [WPFolder] field.

Application.FollowHyperlink does what you want. It does not need a Hyperlink
fed to it, only a string that is the path to the file to open.
 
Can you give me an example of the code I would use, or the properties I
would set on a command button called [cmd_GoToFolder] if I want it to move
to the folder referenced in field [FolderName]?

Rick Brandt said:
Kathy said:
Sorry, I can't find any examples of how that would work in my
situation. Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do
not want to make it a hyperlink field. I want a command button next
to the field, that when you click it, it will open Windows Explorer
and go to the folder named in the [WPFolder] field.

Application.FollowHyperlink does what you want. It does not need a
Hyperlink fed to it, only a string that is the path to the file to open.
 
Actually I figured it out, but I'd like to take it further...

Private Sub cmd_GoToFolder_Click()
Dim txt As TextBox

' Set reference to the txtAddress text box bound to a Hyperlink
field.
Set txt = Me.FileFolder

' Follow the hyperlink.
Application.FollowHyperlink txt, , True

Exit_cmd_GoToFolder_Click:
Exit Sub

Err_cmd_GoToFolder_Click:
MsgBox ("Sorry, that folder does not exist, or that folder is
inaccessible at this time.")

End Sub

BUT I'D LIKE THIS TO WORK FROM SEVERAL FORMS, so my thought was to move it
to a Public Function in a Module, so I can call it from mulitple forms
without having the code copied and pasted in each form. When I paste it in a
Public Function in a Module, it doesn't like the "Me" in Me.FileFolder. Any
suggestions?



Kathy Webster said:
Can you give me an example of the code I would use, or the properties I
would set on a command button called [cmd_GoToFolder] if I want it to move
to the folder referenced in field [FolderName]?

Rick Brandt said:
Kathy said:
Sorry, I can't find any examples of how that would work in my
situation. Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do
not want to make it a hyperlink field. I want a command button next
to the field, that when you click it, it will open Windows Explorer
and go to the folder named in the [WPFolder] field.

Application.FollowHyperlink does what you want. It does not need a
Hyperlink fed to it, only a string that is the path to the file to open.
 
Any help out there? :-)

Kathy Webster said:
Actually I figured it out, but I'd like to take it further...

Private Sub cmd_GoToFolder_Click()
Dim txt As TextBox

' Set reference to the txtAddress text box bound to a Hyperlink
field.
Set txt = Me.FileFolder

' Follow the hyperlink.
Application.FollowHyperlink txt, , True

Exit_cmd_GoToFolder_Click:
Exit Sub

Err_cmd_GoToFolder_Click:
MsgBox ("Sorry, that folder does not exist, or that folder is
inaccessible at this time.")

End Sub

BUT I'D LIKE THIS TO WORK FROM SEVERAL FORMS, so my thought was to move it
to a Public Function in a Module, so I can call it from mulitple forms
without having the code copied and pasted in each form. When I paste it in
a Public Function in a Module, it doesn't like the "Me" in Me.FileFolder.
Any suggestions?



Kathy Webster said:
Can you give me an example of the code I would use, or the properties I
would set on a command button called [cmd_GoToFolder] if I want it to
move to the folder referenced in field [FolderName]?

Rick Brandt said:
Kathy Webster wrote:
Sorry, I can't find any examples of how that would work in my
situation. Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do
not want to make it a hyperlink field. I want a command button next
to the field, that when you click it, it will open Windows Explorer
and go to the folder named in the [WPFolder] field.

Application.FollowHyperlink does what you want. It does not need a
Hyperlink fed to it, only a string that is the path to the file to open.
 
If the textbox is guaranteed always to be called "FileFolder", you could
use

Public Sub GoToFolder(F As Access.Form)
...
Set txt = F.Controls("FileFolder")
...

and the button's Click event procedure would be something like

Private Sub cmgGoToFolder_Click()
GotoFolder Me
End Sub

But I'd probably pass the contents of the textbox, which means you could
do something like this air code:

Public Sub GoToFolder(FolderName As Variant)
If IsNull(Folder) Then
'Field is empty
'Do nothing
Exit Sub

On Error Resume Next
If Len(Dir(Folder, vbDirectory)) > 0 Then
'A folder of that name exists
Application.FollowHyperlink, FolderName, , True
Else
MsgBox "Folder '" & FolderName & "' not found."
End If
Select Case Err.Number
Case 52
MsgBox "Path '" & FolderName & "' not recognised (" _
& Err.Description & ")."
Case Is > 0
MsgBox "Unexpected Error"
End Select
End Sub

Then you'd call it with something like

GoToFolder Me.FileFolder.Value





and call it with

GoToFolder Me.FileFolder


Any help out there? :-)

Kathy Webster said:
Actually I figured it out, but I'd like to take it further...

Private Sub cmd_GoToFolder_Click()
Dim txt As TextBox

' Set reference to the txtAddress text box bound to a Hyperlink
field.
Set txt = Me.FileFolder

' Follow the hyperlink.
Application.FollowHyperlink txt, , True

Exit_cmd_GoToFolder_Click:
Exit Sub

Err_cmd_GoToFolder_Click:
MsgBox ("Sorry, that folder does not exist, or that folder is
inaccessible at this time.")

End Sub

BUT I'D LIKE THIS TO WORK FROM SEVERAL FORMS, so my thought was to move it
to a Public Function in a Module, so I can call it from mulitple forms
without having the code copied and pasted in each form. When I paste it in
a Public Function in a Module, it doesn't like the "Me" in Me.FileFolder.
Any suggestions?



Kathy Webster said:
Can you give me an example of the code I would use, or the properties I
would set on a command button called [cmd_GoToFolder] if I want it to
move to the folder referenced in field [FolderName]?

Kathy Webster wrote:
Sorry, I can't find any examples of how that would work in my
situation. Let me explain better, I hope:

I have a bound field [WPFolder]. It is NOT a hyperlink field. I do
not want to make it a hyperlink field. I want a command button next
to the field, that when you click it, it will open Windows Explorer
and go to the folder named in the [WPFolder] field.

Application.FollowHyperlink does what you want. It does not need a
Hyperlink fed to it, only a string that is the path to the file to open.
 
Back
Top