Update form field after MkDir (1 Viewer)

Samantha

still learning...
Local time
Today, 00:52
Joined
Jul 12, 2012
Messages
180
Happy Friday!

I have been making minor improvements to my database and most recently I have added some code to make a file folder on the network with the click of a button. In order to take this procedure one step further I would like the code to then insert the hyperlink into the hyperlink field on my underlying form. I know I need to do this in VBA because the field names affecting the link could change and I don't want the link to then be broken.

Incase it matters this is what the file name is and the link would need to be.
Code:
 MkDir ("O:\ECBSProposals\" & Left([JobNumber], 3) & "\" & [JobNumber] & " " & CoName & " - " & [ServiceAddress] & ", " & [ProjectDescription])

Table Name - tblProposals
Field Name - Link

Using the following only inserts the text as display text and not the address.
Code:
[Link] = ("O:\ECBSProposals\" & Left([JobNumber], 3) & "\" & [JobNumber] & " " & CoName & " - " & [ServiceAddress] & ", " & [ProjectDescription])

using Link.Hyperlink.Address results in runtime error 7980 Property is read only for this hyperlink
Please point me in the right direction :confused:
 
Last edited:

Samantha

still learning...
Local time
Today, 00:52
Joined
Jul 12, 2012
Messages
180
After researching the error message in further detail I was able to locate another thread to solve my problem. I really don't understand why it works however surrounding the link in # fixes the problem.

https://bytes.com/topic/access/answ...dress-hyperlinksubaddress-read-only-hyperlink

Code:
With Me
    Link.Locked = False
    Select Case "" + ("O:\ECBSProposals\" & Left([JobNumber], 3) & "\" & [JobNumber] & " " & CoName & " - " & [ServiceAddress] & ", " & [ProjectDescription])
    Case Null
    Link = ("O:\ECBSProposals\" & Left([JobNumber], 3) & "\" & [JobNumber] & " " & CoName & " - " & [ServiceAddress] & ", " & [ProjectDescription])
    Case Else
    Link = ("#" & "O:\ECBSProposals\" & Left([JobNumber], 3) & "\" & [JobNumber] & " " & CoName & " - " & [ServiceAddress] & ", " & [ProjectDescription] & "#")
End Select
Link.Locked = True
End With
 

Users who are viewing this thread

Top Bottom