I tried this and it did not work. Here is what I have, maybe you could provide some insight.
Private Sub Command37_Click()
On Error GoTo Err_Command37_Click
Dim sResult As String, sFile As String
Dim sSVR As String, sFLD As String
Dim sUID As String, sPWD As String
Dim sLocalFLD As String
Call fncFileExport
sFLD = ("lifecomm\ClicFtp\Finance\CLIC\DEVL\INBOUND\AccessFTP")
sFile = ("CHQ" & Format(Now(), "yymmddhhnnss") & "UPLOAD" & ".txt")
sLocalFLD = ("S:\Finance\Common\Brent")
sSVR = ("winftp01")
sUID = ("finftp")
sPWD = ("finftp")
MsgBox "Parameters " & sFile, vbInformation, "INFO"
If sSVR = "" Then
MsgBox "Invalid server.", vbExclamation, "E R R O R"
Else
sResult = UploadFTPFile(sFile, sSVR, sFLD, sUID, sPWD)
End If
Exit_Command37_Click:
Exit Sub
Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click
End Sub
---------------------------
Public Function UploadFTPFile(sFile As String, sSVR As String, sFLD As String, sUID As String, sPWD As String) As String
Dim sLocalFLD As String
Dim sScrFile As String
Dim sSource As String
Dim iFile As Integer
Dim sExe As String
Const q As String * 1 = """"
On Error GoTo Err_Handler
sLocalFLD = CurrentProject.Path & "\" & sFLD
' will break if empty folder exist so error to pass
' must create folder first, so API calls work
On Error Resume Next
If Dir(sLocalFLD & "\") = "" Then MkDir (sLocalFLD)
On Error GoTo Err_Handler
sSource = q & sLocalFLD & "\" & sFile & q
sScrFile = sLocalFLD & "\upload.scr"
If Dir(sScrFile) <> "" Then Kill sScrFile
' Open a new text file to hold the FTP script and load it with
' the appropriate commands. (Thanks Dev Ashish !!!)
iFile = FreeFile
Open sScrFile For Output As iFile
Print #iFile, "open " & sSVR
Print #iFile, sUID
Print #iFile, sPWD
Print #iFile, "cd " & sFLD
Print #iFile, "binary"
Print #iFile, "lcd " & q & sLocalFLD & q
Print #iFile, "put " & sSource
Print #iFile, "bye"
Close #iFile
sExe = Environ$("COMSPEC")
sExe = Left$(sExe, Len(sExe) - Len(Dir(sExe)))
sExe = sExe & "ftp.exe -s:" & q & sScrFile & q
' ShellWait sExe, vbHide
DoEvents
Exit_Here:
UploadFTPFile = GetFileText(sScrFile)
DoCmd.Hourglass False
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "E R R O R"
Resume Exit_Here
End Function