Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP from Access VBA

Status
Not open for further replies.

Jonathan

Programmer
Mar 19, 1999
116
0
0
GB
I would like to save some files I'm creating from access on to another machine using ftp. I was under the impression that this could be done, but I can't find out how. The files are probably going to be created by exporting queries.<br>
<br>
Any help on this would be appreciated.<br>
<br>
Thanks<br>
<br>
Jon
 
There are several ActiveX controls you could use for that, or you could stick to 'Microsoft Win32 Internet API' (WININET) from Microsoft, which is a DLL that allows among others ftp-ing files.<br>
<br>
I've however never used WININET, but I have complete function reference on the MSDN library (at least in the one of Oct'98).<br>
<br>
Check out the WININET.DLL in your system/system32 folder...
 
Right:<br>
<br>
I've started to use WinINet (thanks for the tip). However, this is my first attempt at using any of the API things. I've managed to declare all the functions I want, and I've managed to get an FTP connection open and send and receive files using it. There is a function called FtpGetCurrentDirectory that I'm trying to use, and I can't get it to work properly. Here's the declare statement:<br>
<br>
Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" _<br>
(ByVal hConnect As Long, _<br>
ByRef lpszCurrentDirectory As String, _<br>
ByRef lpdwCurrentDirectory As Long) As Boolean<br>
<br>
Here's the detail from the MSDN page:<br>
<br>
Syntax<br>
<br>
BOOL FtpGetCurrentDirectory(<br>
IN HINTERNET hConnect,<br>
OUT LPTSTR lpszCurrentDirectory,<br>
IN OUT LPDWORD lpdwCurrentDirectory<br>
);<br>
The actual syntax of this function varies between its ANSI and Unicode implementations. For more information, see Win32 Internet Functions Syntax.<br>
<br>
Parameters<br>
<br>
hConnect <br>
Valid handle to an FTP session. <br>
lpszCurrentDirectory <br>
Address of a buffer that receives the current directory string, which specifies the absolute path to the current directory. The string is null-terminated. <br>
lpdwCurrentDirectory <br>
Address of a variable that specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating null character. Using a length of MAX_PATH is sufficient for all paths. When the function returns, the variable receives the number of characters copied into the buffer. <br>
Return Value<br>
<br>
Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError.<br>
<br>
<br>
When I call it with my FTP connection, an empty string and 0 for the last parameter, I get false returned and the value of the last parameter is set to 16. When a try calling it with a non zero character for the last parameter, the whole thing just crashes with an Exception:Access Violation message<br>
<br>
Help!!!<br>
<br>
Jonathan
 
Don't worry, I've cracked it.<br>
<br>
Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top