473,471 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How i can stop users running MDB file from another location?

22 New Member
All,

I have MDB which located in network drive, sometime user seems to be copy from drive and pasting in desktop. As i have faced the problem earlier i would like to stop the MDB running from another location now. Any VBA to specifying the path where user can't run MDB from another location. Is there any VBA to fix this problem? Any prompt reply huge appreciated


Thanks,
Oct 29 '11 #1
3 1790
NeoPa
32,556 Recognized Expert Moderator MVP
CurrentDb.Name gives the full path name of the open database. When the database opens you simply check this value against what you know to be valid and if found not to be so, just close the database (or exit Access) with a warning message.
Oct 29 '11 #2
Aaitaman Tamang
22 New Member
NeoPa,

Thanks a lot. I have resolved this problems. The following are codes i have used and working fine

Expand|Select|Wrap|Line Numbers
  1. Dim DP As Variant
  2. Set DP = CurrentDb
  3. If DP.Name = "C:\Documents and Settings\ATAMANG\My Documents\DiasblePath.mdb" Then
  4.  
  5. Else
  6. MsgBox "You are not in the original source. Please ask your Database admin for help"
  7. DoCmd.Quit
  8. End If
Thanks,

** Edit **
New question can now be found at How do I Disable or Dim Sub-Menu Items Based on UserName.
Please post in separate threads in future.
Oct 29 '11 #3
NeoPa
32,556 Recognized Expert Moderator MVP
I'm afraid you haven't tested that very well. That logic is flawed in multiple ways. Not least because other users would not typically have access to the file if it's saved within your profile (as it seems to be).

The first thing you need to do is to move it somewhere generally accessible. If it's on a network then it's the network address you need to check, and maybe an extra check if your PC is sharing it as you would not then typically be using the network version of the address even if you were accessing the same database.

The following code can be considered as a template. It won't work as it stands as I have far too little information to work with :

Expand|Select|Wrap|Line Numbers
  1. Private Const conMDBName As String = "DisablePath.mdb"
  2. Private Const conLocal As String = "C:\LocalPath\" & conMDBName
  3. Private Const conNetwork As String = "\\Server\Share\NetworkPath\" & conMDBName
  4.  
  5. Private Sub Form_Open(Cancel As Integer)
  6.     Dim DP As DAO.Database
  7.  
  8.     Set DP = CurrentDb
  9.     If DP.Name = conLocal Or DP.Name = conNetwork Then Exit Sub
  10.     Call MsgBox("You are not in the original source.  " & _
  11.                 "Please ask your Database admin for help")
  12.     Call DoCmd.Quit
  13. End Sub
Oct 29 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ANSWER | last post by:
Hi, I want to Stop users to import my tables and queries into their database. Is there some VB code or is only solution to make security workgroup permission. If this is the only solution...
3
by: Tommy T-Bag | last post by:
Is there a command that works like the opposite of Shell(Pathname)? I need to stop a running .exe when certain events occur on my Access form. Thanks
30
by: siliconwafer | last post by:
Hi All, I want to know tht how can one Stop reading a file in C (e.g a Hex file)with no 'EOF'?
2
by: jatphat | last post by:
Somebody help me. How do i copy my Access database from one location on my hard disk to another . i tried file.copy(source, distination ) but the file would not move. i always get this error ...
0
by: Dirk Runge | last post by:
Hi! I have embedded Python in an C++ App. The Python-Interpreter is running in its own Thread (I'm using PThreads). I use PyRun_SimpleString to run Python-Code that the user entered in an...
1
by: Hengiccs | last post by:
Dear all, I need to create a ftp program that similar to WinRAR, that allow me to has an option click on right click menu. When i click on that option my ftp program will start run and allow me...
7
by: bwmiller16 | last post by:
Folks - DB2 V9.2 on SUSE 9 Is there a way other than moving the entire /sqllib/db2dump/ (Default database path (DFTDBPATH) = /home/db2inst1 to move just STMMLOG out of there to another...
3
by: shimajavar | last post by:
Hi all I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to...
2
by: mageshwar | last post by:
hi, i have using three functions to scan registry keys (like emptykeys,applicationpatherrors).once the function starts from my button click event, i cant...
2
DjPal
by: DjPal | last post by:
I have a small problem when embedding an swf file in a flash cs4 project (adobe), when run, the embedded video loops continuously. If you play the swf file outside adobe flash, it doesn't loop. Any...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.