We help IT Professionals succeed at work.

Using Access/VBA Function to Dowload a File from the Internet???

2,954 Views
Last Modified: 2013-11-19
I am using the following VBA Function in Access 2010 to download a file from the Internet.  This Function will be used to distribute a new Access Front-End application connected to MySQL Back-End server.  

The problem with the code below is, once the file has been downloaded on the remote machine it will remain in cached.  Therefore, when the next update is published, it will now be downloaded.  It is being pulled from the Cached folder on the local machine.  A workaround is to add a unique id at the end of the file name like  "http://www.somedomain.com/appfolder/MyApp.accdbmm-dd-yyyy-hh-nn-ss" to make it unique each time.

My question ... Is there any modification to the code below that would force it to download the file from the url link instead of using the Cached folder on the local machine????


Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Function DownloadFile()
On Error GoTo err_1

Dim lngPCallerParam As Long
Dim strURLParam As String
Dim strFilenameParam As String
Dim returnValue As Long

On Error GoTo err_1

    strURLParam = "http://www.somedomain.com/appfolder/MyApp.accdb"
    strFilenameParam = "C:\Temp\MyApp.accdb"
    returnValue = URLDownloadToFile(0, strURLParam, strFilenameParam, 0, 0)

Err_Exit:
    Exit Function
   
err_1:
    MsgBox Err.Description
    Resume Err_Exit

End Function


Thanks,

ET
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Eric ShermanAccountant/Developer
CERTIFIED EXPERT

Author

Commented:
Thanks IrogSinta ...  Your solution worked perfectly!!!

ET

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.