Move or copy a "file" to a web site

Knildon

Learning by Default
Local time
Today, 00:22
Joined
Jan 19, 2012
Messages
89
Move or copy a "file" to a web site-SOLVED

Hello everyone,:)
I'm back again with another problem.:confused: Not sure where to post this, so I'll try here first.
I would like to copy a table from my Access Database on my hard drive to an Access Database on a website using VBA coding. Or just copy a small Access Database from my hard drive to a website. (I'll work out the table copy later if that's a problem for now.) I can copy a database to the web using an FTP program but I need this to be done automatically with code.
I've looked high and low on this forum and on the internet but can't come up with an understandable (easy!!) method of doing this.
To do a download I use "URLDownloadToFile" which is simple and easy to use. Is there an equivalent to this somewhere??
Any and all help will be greatly appreciated. A sample code would even be more appreciated if possible.
Thanks in advance for any help.
Don
Still learning by default, trial and error and just plain luck.
 
Last edited:
Write a .bat file to run the native windows FTP-client. Look in windows help or google for arguments of the FTP command. Alle the typed input can come from a file that you can prepare. Then run the .BAT from a Shell within Access. Lookup Shell in the docs.

On websites, the DB is customarily inaccessible from www, and it would require some webservice-like mods to be added to the site, if the upload was to be performed via www.
 
Last edited:
Thanks spikepl for the reply.
Your method sounds like it has merit and may work but injects another bit of code outside of Access. I would like for all of this to happen within the Access/VB database if possible. One mdb file to contend with.
I failed to mention that the website is mine if that matters.
There has to be a way of doing this that doesn't require 2 pages of code to move 1 file to the internet!!!
There are tons of people on the internet asking this same or similar question but all of the answers are either vague or very complicated.
I "think" if I could figure out how to tell Access or VB what the the path is to my website control panel using my username and password I could probably do a file transfer or copy. At least that's what I think!!
In theory, I'm just doing the reverse of a download which copies a file to my computer.
Anyone else out there have any more ideas??
Thanks again spikepl. I may have to give your method a shot if there's no other way to do this.
Don
PS I hate to admit how long I've been working on this but if I ever find an easy way to get it done I'm going to post it on every forum I can find.:D
 
Re: Move or copy a "file" to a web site-SOLVED

Hello to all,
I finally found a way to do this with just 4 lines of code. Impossible, you say. Well here it is:
First, you need to set up an FTP account on your website and set the path to the directory where you want to place your file. Probably public_html.
Next you need a form with a button named uploadmyfile.
Next, from the Insert Menu, you need to insert on the form an ActiveX control named "Microsoft Internet Transfer Control 6.0 and using the properties editor give it the name Inet1.
Here's the code:
Code:
Private Sub uploadmyfile_Click()

'[I]Define where the file is going[/I]
Inet1.URL = "FTP://ftp.mywebsite.com"
'[I]This is the username defined in the FTP account at the website[/I]
Inet1.Username = "username@mywebsite.com"
'[I]This is the password from the FTP account[/I]
Inet1.Password = "password"
'[I]Location of file to be put on the website and location on the website[/I]
Inet1.Execute "", "PUT c:\FileName.mdb FileNewName.mdb"

End Sub
This works but is a little naked for my taste. I added some bells and whistles to mine as shown below. I can't take credit for dreaming this up but it sure did take some time and trial and error to make it work.

Code:
Private Sub uploadmyfile_Click()
On Error GoTo Err_uploadfile_Click
DoCmd.Hourglass True '[I]Show hourglass while file uploads.[/I]
Inet1.URL = "FTP://ftp.mywebsite.com"
Inet1.Username = "username@mywebsite.com"
Inet1.Password = "password"
Inet1.Execute "", "PUT c:\FileName.mdb FileNewName.mdb"
    While Inet1.StillExecuting
      DoEvents
        Wend
Inet1.Execute , "CLOSE" '[I]Close your connection to web site.[/I]
    While Inet1.StillExecuting
      DoEvents
    Wend
DoCmd.Hourglass False  '[I]Turn off the hourglass.[/I]
MsgBox "Upload - Complete!"
Exit_uploadfile_Click:
    DoCmd.Hourglass False '[I]Turn off the hourglass (Precaution).[/I]
    Exit Sub
Err_uploadfile_Click:
    Inet1.Execute , "CLOSE" '[I]Close your connection to web site on an error.[/I]
    DoCmd.Hourglass False '[I]Turn off the hourglass on an error.[/I]
    MsgBox Err.Description
    Resume Exit_uploadfile_Click
End Sub
Hopefully, after all this, I hope someone else can use it.
I also found a longer code to do the same thing with a few more bells and whistles. It's a very nice program and can be found at:
EsZv6D8qeOyKeKfTraLHFbJMFFPlXs09FmidsiCS7yqWKfjjZL3JZfCRZCCHEJP4iIEEs8rwQTAAAAAElFTkSuQmCC
EsZv6D8qeOyKeKfTraLHFbJMFFPlXs09FmidsiCS7yqWKfjjZL3JZfCRZCCHEJP4iIEEs8rwQTAAAAAElFTkSuQmCC
http://www.tek-tips.com/viewthread.cfm?qid=1073963
He also has some examples for A2000, A2003 & A2010 at this location: http://www.homeloanpartnership.com/FTP.zip
Enjoy everyone and I'll see you when I run into my next problem.;)
Don
Learnin' by the minute.:D
 

Users who are viewing this thread

Back
Top Bottom