Solved

using InetTransferLib with Access2000

Posted on 2006-10-30
8
1,315 Views
Last Modified: 2008-01-09
I am trying to implement this solution

http://www.mvps.org/access/modules/mdl0037.htm

'********** Code Start ****************
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Sub TestFTPUpload()
On Error GoTo ErrHandler
Dim objFTP As InetTransferLib.FTP
Const conTARGET = "ftp://ftp.someserver.com"

  Set objFTP = New InetTransferLib.FTP
  With objFTP
    .FtpURL = conTARGET
    .SourceFile = vbNullString
    .DestinationFile = "/2/test.txt"
    .AutoCreateRemoteDir = True
    If Not .IsConnected Then .DialDefaultNumber
    .ConnectToFTPHost "username", "password"
    .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 ****************


I've imported the class modules into my database. When I debug, It isn't recognizing the InetTransferLib.FTP.
It says User defined type not defined. I think I'm missing a reference, but which one? Any help would really be appreciated.
0
Comment
Question by:jefftwilley
  • 4
  • 3
8 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 17834711
Did you download it, the text states:
Download  InternetTransferLib.zip; Beta version. (Requires VB 6 Runtime)

Used it myself successfully...

Nic;o)
0
 
LVL 34

Author Comment

by:jefftwilley
ID: 17834754
Yes, I downloaded it. I have one .mda file and a sample .mdb. I imported the class modules into my app.
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 500 total points
ID: 17834883
While not using it in Addin mode - you need to refer to the class objects themselves.
i.e. there is no qualifier.
(I think that must be a typo in the Access web saying that you should - it makes no sense to).

i.e.
Dim objFTP As FTP

Where you've got the class module FTP.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 34

Author Comment

by:jefftwilley
ID: 17835005
Hi Leigh,
I tried that also, thinking as you did...but it failed because I'd also deleted the "NEW".
I added "NEW" back in and I got it to debug and compile, now to test. I take it you've done this before? :o)
J


0
 
LVL 34

Author Comment

by:jefftwilley
ID: 17835375
Final Solution here.

Sub TestFTPUpload(strSourceFile As String)
' strSource file is the path and file name of the txt file saved by the user.
On Error GoTo ErrHandler
Dim objFTP As FTP
Dim strFileName As String
'strFileName will be the name of the file stripped from the strSourcefile
Const conTARGET = "ftp://ftp.someserver.com"

  Set objFTP = New FTP
  With objFTP
    .FtpURL = conTARGET
    .SourceFile = strSourceFile                               ' Set to vbNullString to bring up the browser
    .DestinationFile = "/Tapp/Test/Work/" & strFileName       ' Depending on login HOME Dir setup, may not need path
    .AutoCreateRemoteDir = False                              ' Set to true to automatically create
    If Not .IsConnected Then .DialDefaultNumber
    .ConnectToFTPHost "username", "password"
    .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
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17835510
You mean you deleted the Set statement?
As long as instantiation occurs - be it explicit or implicit - that's all that matters :-)

Yeah I've used the WinInet.dll code before for FTP.
Pretty reliable.
(Watch the filesize though - you'll not know much error wise if a client even tries to upload a monster file that kills their connection).

I prefer the MSXML object for HTTP posts.

All fun and games though. :-)
0
 
LVL 34

Author Comment

by:jefftwilley
ID: 17835812
I mean I did this

 Set objFTP = FTP     <-----------Failed

instead of this

 Set objFTP = New FTP     <--------Worked

Thanks for your help LP. Muchly appreciated.
J
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17835925
No probs - any time.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question