connect to text file via LAN

S

Suawek

hi,

in my database one of the tables is linked with text file on a server via
LAN. Unfortunately I have to use different login and password to get to the
server, so it fails when I want to get data automatically with my Windows
domain password.
How to refresh table using VBA given that the path is "\\comp-cz\results",
file name is "mytextfile.txt", login is "mylogin" and password "mypassword".
It seems to be much easier to connect to any 'genuine' database, but to
refresh query based on this external text file currently rerquires me to open
the mapped drive and use manually login and pswd (mapping the network drive
does not help - it still asks me to use login)

if it matters - Access 2003, Win XP

Thanks in advance

Slawek
 
D

Douglas J. Steele

How are you mapping the network drive? Take a look at what Randy Birch has
at http://vbnet.mvps.org/index.html?code/network/wnetaddconnection2.htm
(Obligatory warning: Randy's site is aimed at VB programmers, so the
examples often won't port directly into Access. This is one such case: he's
using a control array of command buttons, and Access doesn't support control
arrays. However, you should still be able to figure out what his code is
doing.)

Look at the ConnectNetDrive function, specifically at where he invokes
WNetAddConnection2. Randy's using birchr as the user id, and no password:
you'd replace vbNullString with the password.
 
S

Suawek

Thanks. I mapped it straight in Windows XP, I had no idea how to trigger it
with VBA. Will try the code then

Slawek
 
S

Suawek

is there any way that I can get the same effect using connection instead of
mapping the drive?

Slawek
 
D

Douglas J. Steele

I don't believe so. I don't think you'll be able to create a connection
without presenting your credentials, and I don't believe there's any way to
present credentials other than mapping.
 
D

dbahooker

Douglas is a known troll for whom the only answer is MDB, regardless
of the question
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top