Create hyperlink to open Access form (2 Viewers)

mlai08

Registered User.
Local time
Today, 10:07
Joined
Dec 20, 2007
Messages
110
It creates a shortcut with invalid path - "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE\Intake Test.mdb \cmd 2"

In order to make it works, we need the path properties to show - "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "\\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE\Intake Test.mdb"/cmd 2

Please note that it needs quotation marks to separate the progam path and the target file path with '/cmd 2' without a " at the end.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 18:07
Joined
Jul 9, 2003
Messages
16,287
I haven't looked at this thread in detail so this comment might be completely irrelevant, however it's something I have only just discovered myself so my guess is not many people know about it, therefore it might be worth mentioning.

If you drag a form onto the desktop, it creates a link to it which you can click on (on the desktop) and it opens the form!
 

speakers_86

Registered User.
Local time
Today, 13:07
Joined
May 17, 2007
Messages
1,919
Wow, it does!

Code:
MyShortcut.TargetPath = chr(34) & "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" & chr(34) & " " & chr(34) & "\\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE\Intake Test.mdb" & chr(34) & " /cmd 2"
 

mlai08

Registered User.
Local time
Today, 10:07
Joined
Dec 20, 2007
Messages
110
Unfortunately, the code gives an error of "Invalid procedure call or arguement". :confused:
 

mlai08

Registered User.
Local time
Today, 10:07
Joined
Dec 20, 2007
Messages
110
Finally, I figured out how to make the codes work by using the shortcut's Arguments properties.

Code:
Public Sub test_Click()
Dim WSHShell As Object
Set WSHShell = CreateObject("WScript.Shell")
Dim AccessPath As String
Dim MyShortcut As Object
Dim FEpath As String
Dim ClientDirectory As String
Dim FormID As Integer
 
On Error GoTo Err_test_Click
 
FEpath = "\\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE"
AccessPath = "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
ClientDirectory = "\\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE\Intake Test.mdb"
FormID = Me.IntakeID
 
' Create a shortcut object on the desktop
Set MyShortcut = WSHShell.CreateShortcut(FEpath & "\" & "IntakeForm " & FormID & ".lnk")
 
' Set shortcut object properties and save it
MyShortcut.TargetPath = AccessPath
MyShortcut.Arguments = """" & ClientDirectory & """ /cmd " & FormID
MyShortcut.WorkingDirectory = ("C:\Program Files (x86)\Microsoft Office\Office14\")
MyShortcut.WindowStyle = 4
MyShortcut.IconLocation = ("C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE, 0")
 
MyShortcut.Save
Set MyShortcut = Nothing
Set WSHShell = Nothing
Exit_test_Click:
    Exit Sub
Err_test_Click:
    MsgBox Err.Description
    Resume Exit_test_Click

However, I don't know how to create a hyperlink to point to the shortcut created since the shortcut has a variable number depending on the form ID as highlighted in red below.

"<HTML><Body><a Href='\\officeblrgrp2.office.adroot.bmogc.net\Int_Tech\Technology Resource Repository BE\IntakeForm 2.lnk' target=new>Intake Form Link</a></body></html>"

Can anyone help me out on this?
 

Users who are viewing this thread

Top Bottom