473,729 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access startup - can you run code on database open?

26 New Member
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
  5. If MYPATH = "<server_name>\<path>\<file_name>" Then acCmdOpenStartPage
  6.      MsgBox "NoNo", vbOKOnly, "!!!!!!! ILLEGAL COPY DETECTED!!!!!!!!"
  7.      End If
  8. End Sub
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 44106
3,532 Recognized Expert Specialist
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
26 New Member
Linq, you are a gem!

Thank you so much =)
Sep 2 '07 #3
Shannon Mathews
6 New Member
I can't find that reference in the help for Access2007... is it still valid?
Aug 3 '11 #4
32,569 Recognized Expert Moderator MVP
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

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 can't open the asp pages, because I get an error (Microsoft JET Database Engine (0x80004005) Could not use ''; file already in use.) I wonder if there is a way of being able to read records from the database in an asp script while the database...
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 have been asked to help with a small db project that will reside on our office server and have approx. 5 users. I have installed a copy of MSDE on my development machine and plan on doing
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 open. Is there any way to overcome this behaviour to allow these objects to be edited while other users have the database open?
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 application and will store events that happen in the database (These events happen randomly without pattern, between 10-50 a day) . There are a number of situations where the database is accessed.
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 keep it up to date, but that could probably be done with a macro. At the moment I'm just considoring possible options, so just need to know if it can be done, how easy and a rough idea of how.
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 you proceed to make changes, you may not be able to save them later " Now, when I open the db from different computers, I don't get the error on open, but if I try to open a form in Design Mode. There is a program running that has "control"...
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) application for administrators who have full control over the database objects (tables, forms, queries, and so on ...). the (B) application I have created for normal users who will have only to use forms to insert some data and display data only.
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 message when logging in: 'you do not have exclusive access to the database at this time ... may not be able to save changes'. The message keeps on reappearing. If he hits ok about 30 times, it eventually goes away. Can someone help?
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: DoCmd.DoMenuItem acFormBar, acFile, 2, 0, acMenuVer70 This line opens the import window. Does anyone know the replacement code to use in Access 2007 to open the import window?
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 database. Currently I only know how to use the DoCmd.RunCommand acCmdImport, but the user has to select the tables to be imported and I want this to be automated by the VB code. I want about 3-4 tables to be imported by the code once the user selects...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.