Results 1 to 7 of 7
  1. #1
    AMJADJ is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jul 2018
    Posts
    34

    Email Body Hyperlink to Open Access Form

    Hi All

    We have a process whereby a manager needs to authorise all sample orders. I have a form where users enter all the order information and then on the form,I have created a button that creates a pdf file and emails this to specified users. Currently I have inserted a hyperlink in the email body (which points to Bing).

    However what I would like is the hyperlink to open an access form for a particular record (the id that needs approval) so that the manager can approve. Is this possible? I am not a code expert so please go easy on me ha!



    Please see current code below:

    Code:
    Private Sub Command791_Click()
    Dim appOutLook As Object
    Dim MailOutLook As Object
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    Dim strWhere As String
    
    strWhere = Me.ID
    DoCmd.Close acForm, "Enter New Sample Order"
    DoCmd.OpenReport "Sample Order Form", acViewReport, , "ID = " & strWhere
    
    DoCmd.OutputTo acOutputReport, "Sample Order Form", _
    acFormatPDF, "Location\Sample Form For ID " & strWhere & ".pdf"
    With MailOutLook
    '    .BodyFormat = olFormatRichText
        .To = "receipient1; recipient2"
        .Attachments.Add "Location\Sample Form For ID " & strWhere & ".pdf"
        .Subject = "Test"
        .HTMLBody = "Test HL: <a href='https://www.bing.com/?pc=EUPP_'>Link description here</a>"
        .Send
    End With
    DoCmd.Close acForm, "Enter New Sample Order"
    DoCmd.Close acReport, "Sample Order Form"
    DoCmd.OpenForm "Main Menu"
    End Sub

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    What's the name of the form you want to open? Do you want to open it before the email is sent?
    How does the manager approve/disapprove of the sample now?
    Do you want to take away the ability of the user to send the email?

    Maybe what we need is a description of the new procedures, step by step that has to happen for the email to be sent.

  3. #3
    AMJADJ is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jul 2018
    Posts
    34
    Hi Dave

    Thanks for your response, please see below:

    User Enters Data into Form called "Enter New Sample Order" (This has been completed)
    User Clicks on send for authorisation button which sends and email to the manager (This has been completed - without correct hyperlink in email)
    Manger receives email with subject stating sample order id # requires authorisation (This has been completed - Although above code shows subject as test)

    What I would like now is, if the manager received an email saying order id #5 needs approving, a hyperlink in the email body that will open a form called "Sample Order Approval" with order number 5 being visible. The manager will enter various info to approve.

    I have a test hyperlink being sent out but obviously what I do not know the code for is the hyperlink to open the Sample Order Approval Form.

    Hope this helps and thanks once again for your time.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You can create a shortcut (on desktop or any folder you want) to a particular form by dragging the form name from the navigation pane to the folder.
    This shortcut will work whether the DB is currently open or not.
    However, when navigating to that shortcut via your hyperlink, I don't know of any way to specify criteria for a particular ID.
    Perhaps the email could contain the ID and after the form is opened, the manager could paste the ID into a lookup field on the form to call the proper record.
    Last edited by davegri; 08-25-2018 at 11:04 AM. Reason: another thought

  5. #5
    AMJADJ is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jul 2018
    Posts
    34
    Thanks for that, I have created a shortcut on my desktop to the form. Worse case scenario, the shortcut opens the form prompting the manager to type in the ID of the sample order.
    I have played about with it but no success as of yuet, how do I get the hyperlink to open the desktop file.

    So for example if the file is C:\desktop\authorise.MAF how do I get the hyperlink code to open this file?
    currently it's
    Code:
        .HTMLBody = "Test HL: <a href='https://www.bing.com/?pc=EUPP_'>Link description here</a>"

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    First you have to create the shortcut on the user's Desktop. Look at the properties of the shortcut. It will show a path like C:\Users\usernamehere\Desktop and a name like "Shortcut to formname in databasename.accdb.MAF" (can rename the shortcut).

    So you can build path in code. You need to know the username which can be retrieved with Environ("USERNAME")

    .HTMLBody = "Test HL: <a href='C:\Users\" & Environ("USERNAME") & "\Desktop\Shortcut to formname in databasename.accdb.MAF'>Link description here</a>"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    AMJADJ is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jul 2018
    Posts
    34
    Brilliant! That has worked, thank you for your time

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2018, 10:38 AM
  2. email a form in the body of an email?
    By rudyebiii in forum Forms
    Replies: 2
    Last Post: 10-08-2016, 07:58 AM
  3. Replies: 22
    Last Post: 04-24-2014, 01:56 PM
  4. Replies: 1
    Last Post: 02-05-2014, 09:43 AM
  5. Replies: 1
    Last Post: 02-21-2012, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums