Results 1 to 8 of 8
  1. #1
    Datament is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2023
    Posts
    18

    FollowHyperlink to open a pdf file related to the record in an open form

    I'm new to code writing but I understand access pretty well so I will explain as I understand it. I have a database which contains among others one form frm_RSRV. This form contains four controls, [STORE], [PAID], [DATE], [BANK] and 1 command button btn_chk. Also, the database has the following six pdf files (pdfBANK_A, pdfBANK_B, pdfBANK_C, pdfBANK_D, pdfBANK_E and pdfBANK_F) all saved in C:\Monthlypayments\month\Nov2023.......

    So far this is what i have used FollowHyperlink "C:\Monthlypayments\month\Nov2023\pdfBANK_A......."

    The problem- The above code works and opens only [pdfBANK_A] as specified, I need it to open related pdfBANK_A or pdfBANK_C or pdfBANK_E such that is current in frm_RSRV's control [BANK].

    Help please, thank you in advance!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Concatenate variable reference. If .pdf is not included in the saved text, concatenate it.

    FollowHyperlink "C:\Monthlypayments\month\Nov2023" & Me.Bank & ".pdf"
    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.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    What does your [bank] control actually contain as it should only contain 1 file name. And show the code you are using to open the pdf since as described, nothing should open. Also what type of control is [bank]?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Probably more like

    Code:
    FollowHyperlink "C:\Monthlypayments\month\Nov2023\pdfBANK_" & Me.Bank & ".pdf"
    
    if I understand the question correctly.

    However I can see problems when it comes to Dec 2023 payments?, so that will need variables as well?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Datament is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2023
    Posts
    18
    Yes [bank] control contains only 1 file name at a time. And the control is a textbox. This is the code I am currently using to navigate to that folder FollowHyperlink "C:\Monthlypayments\month\Nov2023" & Me.Bank & ".pdf".

    There are four files [
    pdfBANK_A, pdfBANK_B, pdfBANK_C, pdfBANK_D] in the folder named Nov2023. I need to navigate to the folder Nov2023 and open file pdfBANK_C since this file is the only one that is open in control [BANK]

  6. #6
    Datament is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2023
    Posts
    18
    Yes, you are right. In the AP that Nov2023 has been replaced with [PROC]. And it will not require additional variable in the future.

    [
    BANK] control contains only 1 file name at a time. And the control is a textbox. This is the code I am currently using to navigate to that folder FollowHyperlink "C:\Monthlypayments\month\Nov2023" & Me.Bank & ".pdf".

    There are four files [
    pdfBANK_A, pdfBANK_B, pdfBANK_C, pdfBANK_D] in the folder named Nov2023. I need to navigate to the folder Nov2023 and open file pdfBANK_C since this file is the only one that is open in control [BANK]. The folder Nov2023 is now [PROC]

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Code:
    FollowHyperlink "C:\Monthlypayments\month\"  & Me.Proc & "\" & Me.Bank & ".pdf"
    
    Personally it seems the folder month is not needed ?, so .......

    Code:
    FollowHyperlink "C:\Monthlypayments\"  & Me.Proc & "\" & Me.Bank & ".pdf"
    
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Datament is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2023
    Posts
    18
    Thank you Welshgasman. The second code worked perfectly.

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

Similar Threads

  1. Button to create/open or copy/open an excel file
    By petrikos in forum Programming
    Replies: 23
    Last Post: 10-15-2021, 07:00 AM
  2. Replies: 13
    Last Post: 01-27-2021, 04:09 PM
  3. Cant Get my Buttons to Open a Related Form
    By Steven19 in forum Forms
    Replies: 20
    Last Post: 07-16-2020, 04:46 AM
  4. Replies: 5
    Last Post: 10-11-2017, 03:13 PM
  5. Replies: 1
    Last Post: 05-03-2012, 02:25 PM

Tags for this Thread

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