473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FTP from MS Access?

How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance
Nov 13 '05 #1
16 14888
This is what I use:

Option Compare Database
Option Explicit
Private Const ModEro = 9100

Public Function FTP(ascii As Boolean, send As Boolean, pathname As String,
FileName As String, server As String, serverpathname As String,
serverfilename As String, username As String, password As String, Optional
RstN As String, Optional RstFld As String)
Dim Fs As Object
Dim a As Variant
Dim RST As Recordset
Const script = "__temp_script.tmp"
'---
Dim asciiType As String
If ascii = True Then asciiType = "ascii" Else asciiType = "binary"
'---
Dim SendType As String
If send = True Then SendType = "Put " Else SendType = "Get "
'---create and open the file
Set Fs = CreateObject("Scripting.FileSystemObject")
Set a = Fs.CreateTextFile(pathname & "\" & script, True)
' write all the lines to the file
a.writeline "lcd " & Chr(34) & pathname & Chr(34)
a.writeline "open " & server
a.writeline username
a.writeline password
If (serverpathname <> "") Then a.writeline "cd " & serverpathname
If (ascii) Then
a.writeline asciiType
Else
a.writeline asciiType
End If
If RstN <> "" Then
Set RST = CurrentDb.OpenRecordset(RstN)
Do While Not RST.EOF
FileName = RST.Fields(RstFld) & ".html"
serverfilename = FileName
a.writeline SendType & FileName & " " & serverfilename
RST.MoveNext
Loop
Else
a.writeline SendType & FileName & " " & serverfilename
End If
a.writeline "bye"
'close file
a.Close
sFTP (pathname & "\" & script)
End Function

Private Sub sFTP(stSCRFile As String)
Dim stSysDir As String
'---
stSysDir = Environ$("COMSPEC")
stSysDir = Left$(stSysDir, Len(stSysDir) - Len(Dir(stSysDir)))
Call Shell(stSysDir & "ftp.exe -s:" & stSCRFile, vbNormalFocus)
End Sub

Nov 13 '05 #2
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:

Check out the wininet DLL, e.g. at
http://msdn.microsoft.com/library/de..._reference.asp.
It provides FTP and more without running ugly command-line windows.

-Tom.

How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance


Nov 13 '05 #3
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


Microsoft Access & TCP/IP programming
<...>
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
<....>
Nov 13 '05 #4
RE/
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


One thing to watch for: Proxies. Your code has to be different depending on
whether the app is going through a proxy or not. That drove me nuts for a
couple days until I finally caught on.
--
PeteCresswell
Nov 13 '05 #5
Tony Toews <tt****@telusplanet.net> wrote in message news:<3j********************************@4ax.com>. ..
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


Microsoft Access & TCP/IP programming
<...>

Tony


Tony,

Nice information. The fifth link is broken though.

http://www.planet-source-code.com/xq...s/ShowCode.htm

James A. Fortune
Nov 13 '05 #6
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance

Give this a try...

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

I have had good luck with the class in A97, I haven't tried it in
others.

- Jim
Nov 13 '05 #7
"(Pete Cresswell)" <x@y.z> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


One thing to watch for: Proxies. Your code has to be different depending on
whether the app is going through a proxy or not. That drove me nuts for a
couple days until I finally caught on.


Thanks for the warning. I'll be working on some similar code soon.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #8
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.

Incidentally, in order to use filenames with spaces, this line:
a.writeline SendType & FileName & " " & serverfilename

had to be changed to read thus:
a.writeline SendType & """" & FileName & """" & " " & """" &
serverfilename & """"

Thanks again.
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:nJ*******************@news.xtra.co.nz...
This is what I use:

Option Compare Database
Option Explicit
Private Const ModEro = 9100

Public Function FTP(ascii As Boolean, send As Boolean, pathname As String,
FileName As String, server As String, serverpathname As String,
serverfilename As String, username As String, password As String, Optional
RstN As String, Optional RstFld As String)
Dim Fs As Object
Dim a As Variant
Dim RST As Recordset
Const script = "__temp_script.tmp"
'---
Dim asciiType As String
If ascii = True Then asciiType = "ascii" Else asciiType = "binary"
'---
Dim SendType As String
If send = True Then SendType = "Put " Else SendType = "Get "
'---create and open the file
Set Fs = CreateObject("Scripting.FileSystemObject")
Set a = Fs.CreateTextFile(pathname & "\" & script, True)
' write all the lines to the file
a.writeline "lcd " & Chr(34) & pathname & Chr(34)
a.writeline "open " & server
a.writeline username
a.writeline password
If (serverpathname <> "") Then a.writeline "cd " & serverpathname
If (ascii) Then
a.writeline asciiType
Else
a.writeline asciiType
End If
If RstN <> "" Then
Set RST = CurrentDb.OpenRecordset(RstN)
Do While Not RST.EOF
FileName = RST.Fields(RstFld) & ".html"
serverfilename = FileName
a.writeline SendType & FileName & " " & serverfilename
RST.MoveNext
Loop
Else
a.writeline SendType & FileName & " " & serverfilename
End If
a.writeline "bye"
'close file
a.Close
sFTP (pathname & "\" & script)
End Function

Private Sub sFTP(stSCRFile As String)
Dim stSysDir As String
'---
stSysDir = Environ$("COMSPEC")
stSysDir = Left$(stSysDir, Len(stSysDir) - Len(Dir(stSysDir)))
Call Shell(stSysDir & "ftp.exe -s:" & stSCRFile, vbNormalFocus)
End Sub

Nov 13 '05 #9
Looks like everything I need, short of the aspirin. I'll keep this in mind,
but it's a bit more intense than I hoped for. Then again, learning is always
a good thing (as long as your learning a good thing ;-)

Thanks again

"Tom van Stiphout" <no*************@cox.net> wrote in message
news:il********************************@4ax.com...
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:

Check out the wininet DLL, e.g. at
http://msdn.microsoft.com/library/de..._reference.asp. It provides FTP and more without running ugly command-line windows.

-Tom.

How can one FTP to one's site via VBA (or built in Access control)? Examplesof required funtions would be: file upload, download, delete, rename, move,and director listing.

Thanks in advance


Nov 13 '05 #10
I haven't even checked these out yet, but coming from you,I"m sure there's
great info here. I'll be doing some reading this week, I can see.

Thanks a million for the links.
"Tony Toews" <tt****@telusplanet.net> wrote in message
news:3j********************************@4ax.com...
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examplesof required funtions would be: file upload, download, delete, rename, move,and director listing.


Microsoft Access & TCP/IP programming
<...>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
<...>
Nov 13 '05 #11
Dear TekMaster

I think you are in the same boat as I am, keeping it simple - as long as it
works then that is great.

I would prefer to use some of the other options listed by the other users,
but they seem a lot harder to implement and more importantly, less portable.
If you type FTP in the windows run prompt and then from the prompt type
help, then you get all the commands that are available.

you can then type help close, for example, to find out about the close
command.

Thanks also for your
Nov 13 '05 #12
tekknow wrote:
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.


You can use the same sort of thing, just write out the script file,
execute it like:

Shell "ftp -s MyScript.ftp > output.txt"

You can then read the output.txt file, I use this a lot, my first error
check is to look for lines with val() >499 as these are errors. In this
way I also check (using ls) for files already existing on the FTP server.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #13
Thanks a bunch, Trevor, I was not sure how to output a log file. I'll be
playing with this for a while, for sure.

Thanks again.

"Trevor Best" <nospam@localhost> wrote in message
news:41**********************@auth.uk.news.easynet .net...
tekknow wrote:
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.


You can use the same sort of thing, just write out the script file,
execute it like:

Shell "ftp -s MyScript.ftp > output.txt"

You can then read the output.txt file, I use this a lot, my first error
check is to look for lines with val() >499 as these are errors. In this
way I also check (using ls) for files already existing on the FTP server.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer

Nov 13 '05 #14
I think the only thing I don't like about this is the command prompt, which
may confuse the user (this is for one of my kids, actually).

Thanks for your assist, though. I am using our code for now, since I have no
time to learn the fancy stuff right now.
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:UW*******************@news.xtra.co.nz...
Dear TekMaster

I think you are in the same boat as I am, keeping it simple - as long as it works then that is great.

I would prefer to use some of the other options listed by the other users,
but they seem a lot harder to implement and more importantly, less portable. If you type FTP in the windows run prompt and then from the prompt type
help, then you get all the commands that are available.

you can then type help close, for example, to find out about the close
command.

Thanks also for your

Nov 13 '05 #15
Dear Trevor,

I tried to use that > output.txt, but it does not work, do you have any
hints on that? I just seemed to crash.
Nov 13 '05 #16
WindAndWaves wrote:
Dear Trevor,

I tried to use that > output.txt, but it does not work, do you have any
hints on that? I just seemed to crash.


Maybe Access thinks "> output.txt" is part of the file name to execute?
I haven't tested this, perhaps you need to put the command into a batch
file then execute that.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
2
by: eitsubashkumars | last post by:
I have configured remote access VPN with local pool in ASA firewall however im accessing all the resources(my private network such as servers ) through Asa firewall after getting connected the VPN...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.