Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

using InetTransferLib with Access2000

Posted on 2006-10-30
8
Medium Priority
?
1,359 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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