Is it possible to create via VBA a hyperlink, which could be included in the body of an email, to open a form in an Access database at a given record?
I've tried with the code below:
Private Sub Create_Link_To_Open_Form()
Dim outlookApp as Outlook.Application
Set outlookApp = New Outlook.Application
Dim record_email As Outlook.MailItem
Set record_email = outlookApp.CreateItem(olMailItem)
Dim stringBody, strlink As String
record_email.To = "foo_user@foo.com"
record_email.Subject = "example subject"
'The link should open the form "example_form" at the record with ID=1
string_path = "C:\Path\example_db.accdb?Form=example_form%ID=1"
stringBody = "Click " & "<a href=" & strlink & ">Here</a>" & " to
open the record" & "<br>" _
& "Thank you."
With record_email
.HTMLBody = .HTMLBody & stringBody
End With
record_email.Display
End Sub
And basically the link did not work.
If I just try to open the example_db as in:
string_path = "C:\Path\example_db.accdb"
It works perfectly, so it must necessarily be something to do with how to insert the name of the form and the record within the link, assuming this is possible in the first place.