none
Hyperlink in Access to prompt user to save the file rather than open. RRS feed

  • Question

  • I have a hyperlink in a TextField that has the following code in its on click event:

    application.followhyperlink me.TextField

    When the user clicks on the hyperlink the file is opened.

    However, I would prefer clicking on the Hyperlink  to prompt the user to save the file rather than open it.

    Thank you


    Nath

    Tuesday, March 21, 2017 2:43 PM

Answers

  • Yeah, I'm coming around to the idea of freeing users up from all versioning concerns by replacing the outdated executable on their machine by downloading the latest version of the FE every time they run the local executable.

    Do you know of a good example of this?

    Yeah, thanks for the idea of a message box. I'd like to have a save dialogue then appear.


    Nath

    Hi Nath,

    A quick way to do this is by using a batch file or a VBScript to launch your application. For example, here's what I use right now:

    '8/4/2016
    'thedbguy@gmail.com
    
    Dim fso, wsh
    Dim db, src, dest
    
    'create objects
    Set fso = CreateObject("Scripting.FileSystemObject")
    set wsh = CreateObject("WScript.Shell")
    
    'assign variables
    db = "DatabaseFileName.accdr"
    src = "\\ServerName\ShareName\" & db
    dest = wsh.SpecialFolders("MyDocuments") & "\" & db
    
    'copy FE
    fso.CopyFile src, dest, True
    
    'start FE
    wsh.Run(dest), 1, True
    
    'cleanup
    Set fso = Nothing
    Set wsh = Nothing

    Hope it helps...

    • Proposed as answer by Chenchen LiModerator Wednesday, March 22, 2017 1:34 AM
    • Marked as answer by NaPazz Wednesday, March 22, 2017 6:15 AM
    Tuesday, March 21, 2017 8:35 PM
  • theDBguy gives you a good example.  You could also inspire yourself with http://www.devhut.net/2010/09/15/launch-open-an-ms-access-database-using-a-vbscript-part-2/

    Daniel Pineault, 2010-2016 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Proposed as answer by Chenchen LiModerator Wednesday, March 22, 2017 1:34 AM
    • Marked as answer by NaPazz Wednesday, March 22, 2017 6:15 AM
    Tuesday, March 21, 2017 8:38 PM

All replies

  • Hi Nath,

    You could replace the Hyperlink with a plain Textbox to display the filename and then use a Click event to prompt the user to save the file. However, is it a link to a file on the Internet or a local folder? If local, why would they need to save it again?

    Just curious...

    Tuesday, March 21, 2017 2:49 PM
  • Hi. 

    The linked file is the executable next version of the database.

    I would like the user to click on the link to a fileshare and only be able to save the executable file.

    They would then save it locally.

    Then run the local executable of the database.

    What would the click event on the text box be to prompt the user to save the file?

    Thanks


    Nath

    Tuesday, March 21, 2017 2:54 PM
  • Hi Nath,

    For starters, you could use a MsgBox() to prompt the user if they want to save the file or not. However, if it's for an updated version of the FE, why do you need them to make a decision? Why not just force the issue? Don't you want every user to use the latest version all the time?

    Tuesday, March 21, 2017 3:12 PM
  • Yes, I am checking the version of the database they are running on a splashscreen.

    If it isn't the latest version (Held in another admin database) I show them a hyperlink in a text field to the latest executable on a fileshare and ask them to save a copy.

    The problem is application.followhyperlink opens the .accde file when they click on the link and doesn't prompt them to save it.

    I have tried the file:\\ in the hyperlink but it hasn't stopped the database from opening when the hyperlink is clicked.


    Nath

    Tuesday, March 21, 2017 3:18 PM
  • Hi Nath,

    Pardon me for saying but my point was like this. If you can determine their copy of the database needs to be updated, and you want them to do it, then why do they need to do anything at all? Why can't you simply download a copy of the file from the fileshare to their local machine? Have you looked at any available sample Auto FE updaters?

    Even if you want to allow the user to continue using the older version, there's no need to show them a hyperlink. If you use a MsgBox to ask them if they want to upgrade or not, you can simply download a copy of the new FE for them if they say "Yes."

    To download a copy of the file, you can use the FileCopy command.

    Hope it makes sense...

    Tuesday, March 21, 2017 3:25 PM
  • Hi Nath,

    There are a few sample Auto FE updaters in the UtterAccess Code Archive (and elsewhere), but here's a link to one of them: Front End Automatic Update

    Hope it helps...

    Tuesday, March 21, 2017 3:30 PM
  • Why not automatically download the file from the fileshare every time the db is launched?   This eliminates all bloating and ensures that they always have the latest version.

    Daniel Pineault, 2010-2016 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Tuesday, March 21, 2017 5:24 PM
  • Why not automatically download the file from the fileshare every time the db is launched?   This eliminates all bloating and ensures that they always have the latest version.

    Daniel Pineault, 2010-2016 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    The only reason I could think of is in some cases where users may not want to "always" run the latest copy. Perhaps it's a business rule to have the user make the decision to upgrade or not, depending on their situation.

    Just my 2 cents...

    Tuesday, March 21, 2017 5:38 PM
  • Thanks. 

    Auto updating the FE is the right way to go.

    I'll take a look at the auto FE updater you sent.

    Your help's Much appreciated.

    I just thought users might prefer to save the FE anywhere they like on their machines, so would prefer a save dialogue to show when they click on the hyperlink on the splashcreen, telling them their version had now been outdated by a new one.

    I think I'd still like to know how to make a hyperlink show a save dialogue rather than open a file?


    Nath

    Tuesday, March 21, 2017 8:11 PM
  • Hi Nath,

    Assuming the user "installed" the FE in the first place, then they must have decided where to install it, correct? If so, then any succeeding installs or upgrades should be able to safely assume the user still wants it on the same place. Otherwise, they might get confused if they end up with multiple copies of FEs on their machine without an easy way of knowing which version it is.

    With regards to showing a save dialogue for a hyperlink field, have you tried what I suggested earlier and used the Click event to show a Message Box? For example, in the Click event of the Hyperlink field, try issuing a MsgBox statement just to see if it will work. If so, then we can convert it into a save dialogue.

    Just my 2 cents...

    Tuesday, March 21, 2017 8:18 PM
  • Thanks Daniel.

    I really like the idea of downloading and running the latest version every time the user launches an executable.

    That would free the users up from all versioning concerns.

    Do you have a simple example of such a file, please?

    Nath


    Nath

    Tuesday, March 21, 2017 8:20 PM
  • Yeah, I'm coming around to the idea of freeing users up from all versioning concerns by replacing the outdated executable on their machine by downloading the latest version of the FE every time they run the local executable.

    Do you know of a good example of this?

    Yeah, thanks for the idea of a message box. I'd like to have a save dialogue then appear.


    Nath

    Tuesday, March 21, 2017 8:26 PM
  • Yeah, I'm coming around to the idea of freeing users up from all versioning concerns by replacing the outdated executable on their machine by downloading the latest version of the FE every time they run the local executable.

    Do you know of a good example of this?

    Yeah, thanks for the idea of a message box. I'd like to have a save dialogue then appear.


    Nath

    Hi Nath,

    A quick way to do this is by using a batch file or a VBScript to launch your application. For example, here's what I use right now:

    '8/4/2016
    'thedbguy@gmail.com
    
    Dim fso, wsh
    Dim db, src, dest
    
    'create objects
    Set fso = CreateObject("Scripting.FileSystemObject")
    set wsh = CreateObject("WScript.Shell")
    
    'assign variables
    db = "DatabaseFileName.accdr"
    src = "\\ServerName\ShareName\" & db
    dest = wsh.SpecialFolders("MyDocuments") & "\" & db
    
    'copy FE
    fso.CopyFile src, dest, True
    
    'start FE
    wsh.Run(dest), 1, True
    
    'cleanup
    Set fso = Nothing
    Set wsh = Nothing

    Hope it helps...

    • Proposed as answer by Chenchen LiModerator Wednesday, March 22, 2017 1:34 AM
    • Marked as answer by NaPazz Wednesday, March 22, 2017 6:15 AM
    Tuesday, March 21, 2017 8:35 PM
  • theDBguy gives you a good example.  You could also inspire yourself with http://www.devhut.net/2010/09/15/launch-open-an-ms-access-database-using-a-vbscript-part-2/

    Daniel Pineault, 2010-2016 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Proposed as answer by Chenchen LiModerator Wednesday, March 22, 2017 1:34 AM
    • Marked as answer by NaPazz Wednesday, March 22, 2017 6:15 AM
    Tuesday, March 21, 2017 8:38 PM
  • Thanks very much. 

    I'll give it a go.


    Nath

    Tuesday, March 21, 2017 8:58 PM
  • Thanks very much 

    I'll give that a go too.


    Nath

    Tuesday, March 21, 2017 8:59 PM
  • Hi Nath,

    You're welcome. Daniel and I were happy to assist. Good luck with your project.

    Tuesday, March 21, 2017 9:15 PM