Create hyperlink to folder

G

Guest

Hello,

The following code is used on the double click of a text box so that when a
new job(record) is created the user can double click the box which then
creates a folder on our server at the correct location. This seems to be
working fine but what i need to do is write the value back into the text box
as a hyperlink but i get the error "The hyperlinkAddress is read only for
this hyperlink"

Can anybody help me with this code as i have been trying to create these
links for weeks now but to no avail?

-----------------------------------------------------------
Private Sub txtAttach_DblClick(Cancel As Integer)
Dim drive As String
Dim office As String
Dim NetworkLocation As String
Dim folder As String

If Me.txtDomain.Value = "MWLS" Then
drive = "L:\"
office = "Limerick\"
End If

If Me.txtDomain.Value = "MWLSdub" Then
drive = "L:\"
office = "Dublin\"
End If

If Me.txtDomain.Value = "NORTHERNLIFTS" Then
drive = "L:\"
office = "Belfast\"
End If


folder = drive & "" & "Internal Data\Estimating\" & office & "Pre Award
Projects\" & Me.txtFirstLetter.Value
NetworkLocation = drive & "" & "Internal Data\Estimating\" & office &
"Pre Award Projects\" & Me.txtFirstLetter.Value & "\" & Me.chrJobname.Value

If Len(Dir(folder, vbDirectory)) = 0 Then
MsgBox "Do you want to create a folder at" & folder, vbInformation
MkDir folder
End If

If Len(Dir(NetworkLocation, vbDirectory)) = 0 Then
MsgBox "Do you want to create a folder at " & NetworkLocation,
vbInformation
MkDir NetworkLocation
Me.txtAttach.Hyperlink.Address = NetworkLocation
Me.txtAttach.Hyperlink.TextToDisplay = Me.chrJobname.Value
MsgBox "This folder exists", vbInformation
Else
MsgBox "This folder already exists", vbInformation
End If
End Sub
--------------------------------------------------------
 
D

Dirk Goldgar

Barry said:
Hello,

The following code is used on the double click of a text box so that
when a new job(record) is created the user can double click the box
which then creates a folder on our server at the correct location.
This seems to be working fine but what i need to do is write the
value back into the text box as a hyperlink but i get the error "The
hyperlinkAddress is read only for this hyperlink"

Can anybody help me with this code as i have been trying to create
these links for weeks now but to no avail?

-----------------------------------------------------------
Private Sub txtAttach_DblClick(Cancel As Integer)
Dim drive As String
Dim office As String
Dim NetworkLocation As String
Dim folder As String

If Me.txtDomain.Value = "MWLS" Then
drive = "L:\"
office = "Limerick\"
End If

If Me.txtDomain.Value = "MWLSdub" Then
drive = "L:\"
office = "Dublin\"
End If

If Me.txtDomain.Value = "NORTHERNLIFTS" Then
drive = "L:\"
office = "Belfast\"
End If


folder = drive & "" & "Internal Data\Estimating\" & office & "Pre
Award Projects\" & Me.txtFirstLetter.Value
NetworkLocation = drive & "" & "Internal Data\Estimating\" &
office & "Pre Award Projects\" & Me.txtFirstLetter.Value & "\" &
Me.chrJobname.Value

If Len(Dir(folder, vbDirectory)) = 0 Then
MsgBox "Do you want to create a folder at" & folder, vbInformation
MkDir folder
End If

If Len(Dir(NetworkLocation, vbDirectory)) = 0 Then
MsgBox "Do you want to create a folder at " & NetworkLocation,
vbInformation
MkDir NetworkLocation
Me.txtAttach.Hyperlink.Address = NetworkLocation
Me.txtAttach.Hyperlink.TextToDisplay = Me.chrJobname.Value
MsgBox "This folder exists", vbInformation
Else
MsgBox "This folder already exists", vbInformation
End If
End Sub
--------------------------------------------------------

Since this is a text box that is also a hyperlink, the hyperlink parts
are dependent on the contents of the text box. You have to set the
value of the text box directly. Try this format:

Me.txtAttach = Me.chrJobname.Value & "#" & NetworkLocation

As a side note, it seems odd that you phrase these message boxes as
questions:
MsgBox "Do you want to create a folder at" & folder, vbInformation

.... but don't give the user any choice but "OK", and go on to create the
folder regardless.
 

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