FTP using Access

  • Thread starter Thread starter HSalim
  • Start date Start date
H

HSalim

Hi,
I 'm using the Internet Transfer Library from mvps.org/access.
- well, I actually imported the classes into my XP mdb.

I have not spent the time trying to understand a good portion of the code -
I need to get this done by the end of the day, so hopefully someone will
give me a quick leg up.

I am trying to upload a file and am using the sample code in the read me
file. I have made a few modifications, based on a few guesses.
..DestinationFile - I guessed that it is used to provide a saveAs file name
..AutoCreateRemoteDir - not needed
IF Not .IsConnected - commented not needed for testing atleast

so we chug along nicely till .UploadFileToFTPServer
which is where I get the error. - see error descriotion below.

How can I get past this? I tried calling UploadFileToFTPServer again to no
avail.

HS

ps. I have edited the error description and the code for security, but I
have been careful to not change anything material.




--------------Err.Description -------
220-
220- SomeSite FTP Server
220-
220-Authorized access only. All access is logged. Violators will
220-be prosecuted.
220-
220 Welcome to the SomeSite FTP Server.
331 Password required for HSALIM.
230 User HSALIM logged in.
-----------------------------------


'********** Code Start ****************
Sub TestFTPUpload()
On Error GoTo ErrHandler
Dim objFTP As FTP
Const conTARGET = "ftp://ftp.somesite.com"

Set objFTP = New FTP
With objFTP
.FtpURL = conTARGET
.SourceFile = "C:\TestExport\testfile.txt"
'.DestinationFile = "/2/test.txt"
'.AutoCreateRemoteDir = True
'If Not .IsConnected Then .DialDefaultNumber
.ConnectToFTPHost "HSALIM", "mypassword"
.UploadFileToFTPServer
End With
ExitHere:
On Error Resume Next
Set objFTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly,
Err.Source
Resume ExitHere
End Sub
'********** Code End ****************
 
HSalim said:
Hi,
I 'm using the Internet Transfer Library from mvps.org/access.
- well, I actually imported the classes into my XP mdb.

I have not spent the time trying to understand a good portion of the
code - I need to get this done by the end of the day, so hopefully
someone will give me a quick leg up.

I am trying to upload a file and am using the sample code in the read
me file. I have made a few modifications, based on a few guesses.
.DestinationFile - I guessed that it is used to provide a saveAs
file name .AutoCreateRemoteDir - not needed
IF Not .IsConnected - commented not needed for testing atleast

so we chug along nicely till .UploadFileToFTPServer
which is where I get the error. - see error descriotion below.

How can I get past this? I tried calling UploadFileToFTPServer again
to no avail.

HS

ps. I have edited the error description and the code for security,
but I have been careful to not change anything material.




--------------Err.Description -------
220-
220- SomeSite FTP Server
220-
220-Authorized access only. All access is logged. Violators will
220-be prosecuted.
220-
220 Welcome to the SomeSite FTP Server.
331 Password required for HSALIM.
230 User HSALIM logged in.
-----------------------------------


'********** Code Start ****************
Sub TestFTPUpload()
On Error GoTo ErrHandler
Dim objFTP As FTP
Const conTARGET = "ftp://ftp.somesite.com"

Set objFTP = New FTP
With objFTP
.FtpURL = conTARGET
.SourceFile = "C:\TestExport\testfile.txt"
'.DestinationFile = "/2/test.txt"
'.AutoCreateRemoteDir = True
'If Not .IsConnected Then .DialDefaultNumber
.ConnectToFTPHost "HSALIM", "mypassword"
.UploadFileToFTPServer
End With
ExitHere:
On Error Resume Next
Set objFTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly,
Err.Source
Resume ExitHere
End Sub
'********** Code End ****************

Let me say up front that I don't know that much about FTP and have only
use the InetTransferLib for HTTP. So this may well be a naive question,
but if the error being reported derives from the server response "230
User HSALIM logged in.", is it trying to tell you that you're already
logged into the FTP server, and it won't let you login twice at the same
time? Do you have an open FTP session with this server, or a browser
window open on the FTP site?
 
Hi Dirk,
Thanks for the reply. I managed to solve the problem - after I caused it
myself!
It was in .DestinationFile - (that is a required parameter),
so when I used the source file name in destination file it worked.

Because it was a required parameter, the function called failed at
initiation. it did not even attempt to put the file on the server.
Therefore, The error message is just a log of the responses from the FTP
server, I guess.
Had the put operation been unsuccessful, the error message/log may have been
different. (I'd expect the top of the log would get flushed as new lines
are added to the bottom.)

Regards
HS
 
HSalim said:
Hi Dirk,
Thanks for the reply. I managed to solve the problem - after I
caused it myself!
It was in .DestinationFile - (that is a required parameter),
so when I used the source file name in destination file it worked.

Because it was a required parameter, the function called failed at
initiation. it did not even attempt to put the file on the server.
Therefore, The error message is just a log of the responses from the
FTP server, I guess.
Had the put operation been unsuccessful, the error message/log may
have been different. (I'd expect the top of the log would get
flushed as new lines are added to the bottom.)

Thanks for the information. I'll bear it in mind for the future -- I've
got a project waiting in the wings that will probably involve FTPing
from Access.
 
Back
Top