Question : how run a macro(that does some tests) the moment MS Acess fires

hello there experts,

i have an ms access application. i want to sell each copy of it to some people-customers. i must somehow lock the access application.

what i have done is this.

1) before i send them the access application in a cd i send them an excel file
2) in this excel file there is a button and a macro written in vba. when someone clicks it, a new hidden sheet is created and in a cell the name of the computer is written.
3) it is all oblivious to the user and then he has to send me back the .xls file

so i know his computer name.

then i need to write some code in the access application(that i have already) that will read the computer name and compare it with the computername i already have. if it is the same i need to open the access database. if not i must hide all windows and hide and make all database objects inaccessible.
below folows the code that i find the computername.

well i need to tell me which is the first event that fires when i open an access file.in excel it is workbook_open. in access which is that event? and when i find it, how i hide and make unusable all the database objects if the comparison of the computer names are not the same?

is this a secure way to lock the application?

thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Private Declare Function GetComputerName Lib "kernel32" _
    Alias "GetComputerNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long
 
 
Function ReturnComputerName() As String
Dim rString As String * 255, sLen As Long, tString As String
    tString = ""
    On Error Resume Next
    sLen = GetComputerName(rString, 255)
    sLen = InStr(1, rString, Chr(0))
    If sLen > 0 Then
        tString = Left(rString, sLen - 1)
    Else
        tString = rString
    End If
    On Error GoTo 0
    ReturnComputerName = UCase(Trim(tString))
End Function

Answer : how run a macro(that does some tests) the moment MS Acess fires

Nicolaosk:
The application should run with Runtime.
The User Should NOT be required to purchase Access 2007.
Just Package it up with ruintime on an XP Machine
I did that and two people who do not have Acess insatlled ran the app - no problem
see:
 http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23067485.html
Process for getting name and building a key.
In a Macro named Startup I have a Macro named   Autoexec.
         When access starts to will automatically run this macro
In the MAcro I have a line
Condition    - modCheckforEULAorRFP("EULA Agreement")
Action         - OpenForm
Form Name  - frmEULA  

Form frmEULA has on open code that gets the computer name, checks if a license key is entered, checks for license end date etc.
  If there is no KEy then I set a 30 day trial .
  Also generate an encrypted key based on "Trial", "Single User", "Enterprise"
  If the license type is blank I make it "Trial" and build a key.
The info I want from the user is saved in a Usys Table.
I then print a report with the info or let them send me an email through outlook (all access VB code)
I now have the computer name and the license they want.
If they decide to purchase I email them back a key.
My Access code (when the license opens) allows them to enter a key.
If they enter a key and the reverse encryption results in "User" or "Enterprise" I change the Application Name to "RFP Manager"
Then the frmEULA is never opened.

When the application is ready to be distributed.
Set Application name  -  Tools  >  Startup set Application name to "EULA Agreement"

Later in the MAcro I have :
Condition    -  modCheckforEULAorRFP("RFP Manager")
Action         - OpenForm
Form Name  - SwitchboardLogin

I do other code in the app so when the login form starts  I test fo "Trial" and display an expiration date.

My Key is based on Start(Installation Date), Trial Period, License Type and computer name.
If they ask for another trial period I send them a new key when they enter it.
I run code that gets the Install date from the access table, the computer name and builds a key based on the Install Date, Name, Period and the text "Trial" "Single User" or Enterprise.
If no match then I build a key based on Install Date, 60 day period and "Trial".
If no match then it is an invalid key.
If there is a match I reset the end date for the trial.

If I give you the code I have then the encryption would be in the public domain.
I can't do that.  I will look into a revised version but it will take some time and with my schedule would be a couple of weeks.
Right now I am converting a system from A97 to 2007 , with a new menu system, and since it is a client I have to get that done first.
Over the next day or two I will see what I can release.
Don

Random Solutions  
 
programming4us programming4us