Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using InetTransferLib with Access2000

Posted on 2006-10-30
8
Medium Priority
?
1,371 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 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…
Suggested Courses

886 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