473,422 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

Access startup - can you run code on database open?

JodiPhillips
MS Access2000

Hi everyone,

I've searched the forums for an answer to this question and nothing jumps out at me.

When a database is opened I want to automatically run code (at start-up) that compares the path of the opened database to a specific path (where the original database is located). This is for security reasons - I need to know if the original database has been copied without authorisation. Due to network issues I cannot use intrinsic MSAccess groups and permissions and have setup security that operates from within Access - ie log in table, and of course the original database is vulnerable to being copied.

This is the very bare bones - very basic code for the comparison (don't laugh - in this format its just for testing to see how I can get it to load at startup - it works fine though).

Expand|Select|Wrap|Line Numbers
  1. Sub MYPATH()
  2. Dim MYPATH
  3. MYPATH = CurDir
  4.  
  5. If MYPATH = "<server_name>\<path>\<file_name>" Then acCmdOpenStartPage
  6.      MsgBox "NoNo", vbOKOnly, "!!!!!!! ILLEGAL COPY DETECTED!!!!!!!!"
  7.      End If
  8. End Sub
  9.  
StartPage opens my log-in splash form (frmLogSplash) where users enter their userid and password (this compares the password stored in the log-in table and if its good then they continue to the next user form - if its not after three attempts the application closes).

The startup options in Access only allow me to open a form, load a menu bar, a shortcut menu, or set the bypass key.

So to get to the point of this post - can you script an autorun on open type event in Access? That is can my dir/path script be made to run each time a database is opened? If so, can anyone point me in the right direction on how to go about this? (I'm happy to have a go at working out the scripting myself, just need some guidance on how to). I'm also very willing to be guided on improving the above code (remember though that this is just a two second job for testing)

Thanks everyone =)
Sep 2 '07 #1
4 44045
missinglinq
3,532 Expert 2GB
Goto Access Help and enter the search term Autoexec. Then click on Carry out an action when my database first opens. This will tell you about the Autoexec Macro, a special macro that runs automatically when a database opens. You'll need to put your verification in a function, then in the Macro builder under Action choose Run Code then place the function name in the appropriate box.

Linq ;0)>
Sep 2 '07 #2
Linq, you are a gem!

Thank you so much =)
Sep 2 '07 #3
I can't find that reference in the help for Access2007... is it still valid?
Aug 3 '11 #4
NeoPa
32,556 Expert Mod 16PB
Probably not Shannon.

Look instead at Tools \ Startup \ Display Form/Page. If you enter a valid form in there you can ensure the form has code in its FormOpen event procedure.
Aug 4 '11 #5

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

Similar topics

2
by: Nicolae Fieraru | last post by:
Hi All, I have some asp pages which use a local Access database. I want to add different records to the database and also to be able to browse the page. When the database is open in MS Access, I...
4
by: Phil | last post by:
Hi all, I need some help to access an SQL db on another machine. I am using VB.NET and remoting to make a client/server connection...although I don't think this is relevant to the question. I...
1
by: Alan Jones | last post by:
Access 2000 onwards introduced a restriction that only allows you to edit and save forms, reports and macros when you have exclusive access to the database, i.e. no other user has the database...
4
by: Macca | last post by:
Hi, I have an windows forms application that accesses a SQL database I have a few questions as to connecting to the database. This application will run 24 hours a day. It is a monitoring...
17
by: Flic | last post by:
Is this possible? I know about a bit about ODBC and found how to import an ODBC database stored on the computer, however I am after accessing an SQL database stored on a webserver. I'd like to...
9
by: shades234 | last post by:
When i go to open my Access database from certain computers, i get multiple popup messages stating the same thing. They all say "You do not have exclusive access to the database at this time. If...
5
meLady
by: meLady | last post by:
Hello, I have two database applications and they are: - the (A) application is for administration use. - the (B) application is for normal users use. the idea is that: I made the (A)...
2
by: Zippy | last post by:
I recently updated one of my clients from Access 97 front-end to Access 2003. (Database still in 97 format). They have about 5 networked PCs. On one of these PCs only, the user gets a warning...
2
by: Reedsp | last post by:
I have a Access 2000 formated database that I am testing the functionality of the database in Access 2007. One line of code of visual basic code in not working in a module. The line is: ...
0
by: hawthan | last post by:
Hello All, I am looking for simple VB code that will ask the user to select the access database that contains the tables that will be imported based on code and utilized by queries in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.