Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restricting number of times DB is opened 1

Status
Not open for further replies.

Yardyy

Technical User
Aug 13, 2002
448
GB
Hi, Would anyone know how i can restrict our users from using the database, essentially what we need is the DB not to open and just goto a custom form, were we can tell them to contact support for an updated DB. So after say 1000 times the DB has been opened, they need to contact us for a new Front End or Full DB.

It would also be advantageous if we could set a time limit on it, so say after the first usage, they can only use it for 6 months, ot till the end of the financial year.

Many Thanks
Yurov Ardyy
 
Create a table to hold a value. In your autoexec macro, update the value. Add some code that checks this value and, if necessary, displays a message box informing the user that the db will close.

One question that begs to be asked --- WHY ???


Randy
 
Hi, i like the idea, would you know where i could get some sample code for this.

We have sales folk on the road, who are using data that is very old, some about 9 monthns and older, we thought that that after say 300 uses based on 2 uses a day, would then ask the sales to contact us for an updated stock db, but they dont always do that. So the other way was to enforce it so that after 260 uses they get a message saying that need to contact us guys, cos after another 40 uses it will expire.

Many Thanks
Yurov Ardyy
 

How about...

Create a new table
tblDatabaseUsage -- with 2 fields
UsageID - Number (set to 1)
NumberOfUses - Number

Design a new query
qryDatabaseUsage
"UPDATE tblDatabaseUsage SET NumberOfUses = [NumberOfUses] + 1 WHERE UsageID = 1"

Build a PUBLIC Function in a new module
Code:
Public Function DatabaseUsage()
    Dim intCounter As Integer
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryDatabaseUsage"
    DoCmd.SetWarnings True
    intCounter = DLookup("NumberOfUses", "tblDatabaseUsage", "UsageID = 1")
    Select Case intCounter
        Case Is > 200
            MsgBox "This database is out of date ...", vbOKOnly & vbCritical, "Database Usage Exceded"
            DoCmd.OpenForm "frmNoAccess"
        Case Is = 200
            MsgBox "This is the last time this database can be used ...", vbOKOnly & vbInformation, _
                "Last Available Usage"
            DoCmd.OpenForm "frmMain"
        Case Is > 174
            MsgBox "You only have " & 201 - intCounter & " uses left before this database expires ...", _
                vbOKOnly & vbInformation, "Database Usage Critical"
            DoCmd.OpenForm "frmMain"
        Case Else
            DoCmd.OpenForm "frmMain"
    End Select
End Function

Create a new Macro
Macro Name: Autoexec
Action: RunCode
Function Name: DatabaseUsage()

The autoexec macro will run every time the database is opened.


Randy
 
Randy700, thanks for this, i will test it out and report back asap. many thanks again.

Many Thanks
Yurov Ardyy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top