Hey, I've integrated the FTP Code created by 1DMF (Found is FAQs) into my database which is working great. I need to upload two separate files though. What I have done is bound the FTP Form to a table and placed two records in the table, each with different file names and different URL locations.
However I can't seem to get it to work. I tried moving through the records by opening a record set to the table and looping through the records using While and Wend, but it doesn't recognised the FTPFile function and come up with an error; "Argument not optional"
Any suggestions on how I can upload two files using the FTP code in the FAQ by 1DMF?
Here is the code snippet attached to the button, the module is working fine:
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
However I can't seem to get it to work. I tried moving through the records by opening a record set to the table and looping through the records using While and Wend, but it doesn't recognised the FTPFile function and come up with an error; "Argument not optional"
Any suggestions on how I can upload two files using the FTP code in the FAQ by 1DMF?
Here is the code snippet attached to the button, the module is working fine:
Code:
Private Sub Command16_Click()
On Error GoTo Err_Upload_Click
Dim db As Database
Dim rs As Recordset
Me.lblLink.Caption = "Uploading Database, please wait..."
Me.lblLink.Visible = True
Set db = CurrentDb
Set rs = db.OpenRecordset("FTPTbl", dbOpenDynaset)
With rs
.MoveLast
.MoveFirst
While Not .EOF
' Check for Selected file
If Nz(!FileName, "") = "" Then
MsgBox "Please select file to upload first!"
Exit Sub
End If
' Check for FTP Server
If Nz(!domain, "") = "" Then
MsgBox "Please enter FTP Domain!"
Exit Sub
End If
' Check for UserName
If Nz(!UserName, "") = "" Then
MsgBox "Please enter User Name!"
Exit Sub
End If
' Check for Password
If Nz(!pword, "") = "" Then
MsgBox "Please enter Password!"
Exit Sub
End If
' Set Default upload directory to root if nothing supplied
If Nz(!Directory, "") = "" Then
Me!ServerDir = "/"
Me.Refresh
End If
' Upload file
If FTPFile(!domain, !UserName, !pword, !FileName, !Directory, !tfrmode) Then
'MsgBox "Upload - Complete!"
End If
.MoveNext
Wend
End With
Set rs = Nothing
Set db = Nothing
Exit_Upload_Click:
Exit Sub
Err_Upload_Click:
MsgBox "Error in Upload_Click : " & Err.Description
Resume Exit_Upload_Click
End Sub
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."