Link to home
Start Free TrialLog in
Avatar of pfleischer
pfleischer

asked on

Block run of database if it is in a network folder

I have a database.  (split into front and backend)
Users are instructed to run this from their C: hard drive OR from a flash drive, then back up to their folder on the network (always mapped as Y:)

I would like to BLOCK the run, if it is over the network.  It slows down for the user, and for everyone else on the network.

What code can I insert to check the drive on the path.  (so.. I don't want it to run off the Y: drive.. I DO want it to run off the C: drive.. OR.. off the users E:, F: or whatever other path their flash drive connects as.
SOLUTION
Avatar of Raynard7
Raynard7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The volume of users in a networked system will have some impact - but the main impact will be the network speed itself.

You can speed it up by optimising your query speeds and using some connection tricks.

Using queries, you could have a kind of "log in" table.

Same as your back up facility (but other way around).
When a user opens the database, simply INSERT a record to the table.

Then run another query to count how many people are in the table (as they are logged in).
If too many, kick the user out.

When a user logs out, you run a DELETE query to minus off one user...

Idea...?
Avatar of pfleischer
pfleischer

ASKER

Danny... I'm not going to try to solve our network issues.. that's someone elses job :-)   but I REALLY don't want to have users slow down (really, its painful) and abandon this application.  we are still in an 'adoption' mode.. so I want success!

Raynard, that looks really simple.
where do I actually put that code?
I don't want to block the BACKUP.. I want to block the run of the whole application
so.. can I put this in the startup for the Menu form?

then maybe redirect to a different form, that gives info about why they are not getting the menu..

Paula
Avatar of rockiroads
Paula, is it fair to say you do not want it run if its on any network drive? You may want to consider not hardcoding paths just in case you move location or user has mapped to a different letter.


We can go for one of two choices

1. Check path is a network drive
2. Check path is a local drive (users may have a C and a D drive)

Well either way, its just one API call

add the following in a new module in Access




Private Declare Function PathIsNetworkPath Lib "shlwapi" Alias "PathIsNetworkPathA" (ByVal pszPath As String) As Long
 
Public Function IsPathNetPath(ByVal sPath As String) As Boolean
   IsPathNetPath = PathIsNetworkPath(sPath) = 1
End Function





Now what u do is add a check in either a startup form or a macro (startup Macro is called AutoExec)

Lets say a form, if your application has one form that is always called on startup, add the following code to Form_Open

private sub Form_Open(Cancel as Integer)
    If IsPathNetPath(CurrentProject.Path) = True then
        Cancel = True
        msgbox "Sorry, but running this application from the Network is not allowed. Please contact Paula for more information.",vbInformation,"Access Denied"
        Application.Quit
end sub
One thing, if user runs from flash drive then this may return FALSE
I dont have one - too poor :(
so I cant test to see what value it returns
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To go for overkill ... I have a settings table I use to validate all sorts of things at startup and I would place that table on the netwrok so if I ever needed to change the 'Y' I can do it as a configuration and not redistribute the whole app.

Steve
THANKS everyone.  THis all works perfectly now.
I put it in code when the Menu loads - so users get a msgbox, instead of the menu if it is on the wrong drive.

Our users are not savvy enough to put this on other network drives ;-)

The history is:  
This was INTENDED to run off the network for backup purposes, but we discovered 2 weeks into implementation (and of course AFTER training and users had set up their files) that our network couldn't handle 100 teachers all getting on after school to enter their data and run reports.

SO.. I sent out an email, instructing everyone to copy the whole folder to their C drives, and BACK UP to their Y drives.  The tech-savvy ones were able to follow the directions.   Others, just ignored the email as "too techy" and left it on their Y drive.  About March or April, as their files got larger, their processing time slowed horribly.  When I got those frustrated "why is this so slow" emails, I just forwarded them the October directions for moving their files.  Some did... some didn't.  :-P  

BUT.. they slow down other processes, and I really don't want this application to bog down the whole system next school year.  So this is PERFECT!!  again thanks and thanks and thanks Paula