Solved

Block run of database if it is in a network folder

Posted on 2006-07-13
8
227 Views
Last Modified: 2006-11-18
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.
0
Comment
Question by:pfleischer
8 Comments
 
LVL 35

Assisted Solution

by:Raynard7
Raynard7 earned 400 total points
ID: 17104544
if currentproject.path like "Y:\*" then
    'Do Not Run Backup
else
    'Run Backup
end if
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 17104674
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...?
0
 
LVL 1

Author Comment

by:pfleischer
ID: 17104900
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
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17106567
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
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 65

Expert Comment

by:rockiroads
ID: 17107206
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
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 100 total points
ID: 17107222
if u go the hardcoded route and not run on Y, and u want it in vba then small tweak to Raynard7's code

if currentproject.path like "Y:\*" then

should be

if left$(currentproject.path,3) = "Y:\" then
    msgbox "We on the Y Drive!!!"
end if


Now, what if the user ran from another network drive, are you going to allow that?
0
 
LVL 39

Expert Comment

by:stevbe
ID: 17107566
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
0
 
LVL 1

Author Comment

by:pfleischer
ID: 17115218
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now