Sign in to NAS with username and password through windows explorer (smb) (1 Viewer)

SHOTOKANKATANA

New member
Local time
Today, 20:03
Joined
Dec 4, 2021
Messages
17
Hi,

Hopefully I'm not posting a question already asked.
I have trouble finding a solution...

I have an access DB that writes reports to my desktop.
It also writes reports to the lan server but I have to sign into this server from windows explorer before the code works.
It throws a managed error if the connection has not yet been established, which makes total sense

When I boot my pc and connect to the network server through windows explorer like so: \\192.x.x.x before using the form control to create and store reports everything works fine and as expected. For as long as the pc stays powered on I can keep using the report creation/storing button just fine. After a reboot though I have to connect to the server through the explorer again first to prevent the error.

I understand why it acts like this, without the server connection the coded path's don't yet exist so it can't reach the location...

What I like to do is just work from the DB without signing in through windows explorer first.

I tried many things in code that all work but only if the connection is already established through windows explorer.

Is there a vba way to pop up windows explorer asking for username and password to connect to the server if the report button is used while the connection is not yet established through explorer? If possible I would prefer to do this without mapping the network drive. I have code in place to test if the server has an active connection with the pc but I can't figure out how to establish the connection by signing in with my username and password like I would do through windows explorer if the connection was not yet created, for example after booting the computer...

Hope this makes sense... English is not my native language...

Thanks in advance for any pointers in the right direction!
 
You should be able to make the network connection permanent, so you do not have to log in each time.
If you manage it by hand for the first connection, there is an option to remember the connection?
 
I could map the drive no problem there, but that would make the drive visible for anyone using my desktop, which I'd rather not do.
It has sensitive information so preferably I keep this drive/server away from "this pc" or "network loactions"

A permanent connection without ever needing to sign in would not be optimal.

The way it works with windows explorer is actually quite good for me. It would just be handy if that would be possible through vba as well.

It should be possible I think. Not sure though...

I mean if explorer is used to navigate to the server IP which results in a windows user sign in popup for the first connection shouldn't there be a way to sort of mimic this with vba? I'm just thinking out loud...
 
I have found some examples which use FSO but have not been able to get them to work. Most of the forums about this relate to mapped network drives. Not my preferred choice but I'm beginning to think it might be the only way though...
 
if mapping solves your issue, you could always at the start of the process map the drive, then on completion, remove the mapping. This link may be of interest

Also found this link
 

Users who are viewing this thread

Back
Top Bottom