Return to Snippet

Revision: 8018
at August 27, 2008 04:03 by goo


Initial Code
Function FTP_Data()
'=========================================================================
'FTP from Microsoft Access
'by Matthew V Carmichael
'Craetes FTP Batch File, FTP command file (txt)
'Default directory location of files to upload/download is
'the same location as the mdb file that contains this module.
'========================================================================='
On Error GoTo Err_Trap
 
    Dim pFile As Long
    Dim strPath As String
    Dim strFileName As String
    Dim ftpServer As String
    Dim strUserName As String
    Dim strPassword As String
    
    'Path and Name of file to FTP
    strPath = CurrentProject.Path & "\"
    strFileName = "Test.mdb" 'Name of file to upload
    'FTP Server Settings
    ftpServer = "Your FTP Server"
    strUserName = "Your FTP User Name"
    strPassword = "Your FTP Password"
    
    'Create text file containing FTP commands
    pFile = FreeFile
    Open strPath & "FTP_cmd.txt" For Output As pFile
    Print #pFile, "user"
    Print #pFile, strUserName
    Print #pFile, strPassword
    Print #pFile, "Put " & strFileName
    'Use the Put command to upload, use the Get command to download.
    'Print #pFile, "Get " & "Your File Name"
    Print #pFile, "quit"
    Close pFile
    
    'Create batch file to execute FTP
    pFile = FreeFile
    Open strPath & "FTP_Run.bat" For Output As pFile
    Print #pFile, "ftp -n -s:" & "FTP_cmd.txt " & ftpServer
    Print #pFile, "Pause"
    Close pFile

    'Execute FTP command
    Shell strPath & "FTP_Run.bat", 1
    
Err_Trap_Exit:
    Exit Function
    
Err_Trap:
    MsgBox Err.Number & " - " & Err.Description
    Resume Err_Trap_Exit
 
End Function

Initial URL
http://www.myaccesstips.com/Functionality/ftp.html

Initial Description


Initial Title
ACCESS FTP Upload

Initial Tags


Initial Language
Visual Basic