Solved

using InetTransferLib with Access2000

Posted on 2006-10-30
8
1,343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

623 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