Question : How do you create ODBC in VBA to retrieve a text file from remote server then populate access table?

How would you do the same thing  as below, but just retrieving a text file from a remote (ftp)server on our network so I can populate a table in my access database? I need to do this in VBA. Linking tables on remote servers with local odbc does not work in Access.

Rank: Genius
Arthur_Wood:Dim conn as ADODB.Connection
Dim rs as ADODB.Recordset

Set conn = New ADODB.Connection

conn.ConnectionString = "Driver={SQL Server};" & _
           "Server=MyServerName;" & _
           "Database=myDatabaseName;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"
conn.Open

Dim strSQL as String

strSQL = "Select * from MyTable"

Set rs = conn.Execute(strSQL)


try that, for a start.

AW



Answer : How do you create ODBC in VBA to retrieve a text file from remote server then populate access table?

ODBC cannot retrieve a text file.  It can link to database tables in other DB apps such as FoxPro, Oracle, MS Sql, etc.  and pass down queries for the host db to execute, returning a recordset.  To copy a textfile in a folder on a remote server, you need to use Windows file management tools, or functions like FileCopy from within Access.  Before you open Access can you map the remote server to a drive letter, access the folder using Windows Explorer, highlight the file name, press Ctl+C, and then navigate back to your local machine, select the directory, and using Ctl+V, paste the text file in the folder?  If you cannot do that, then there is no way a function within Access will be able to do it.
Random Solutions  
 
programming4us programming4us