Solved

using InetTransferLib with Access2000

Posted on 2006-10-30
8
1,277 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 34

Author Comment

by:jefftwilley
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 34

Author Comment

by:jefftwilley
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No probs - any time.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now