RE: I didn't think of this




Klatuu,

I found the code I need looking at other posts in this forum. Apart from a
few changes, I believe this code was written by you for someone else :-)
Thanks a million Klatuu for your response and willingness to help. We really
do need you here!!

' Here's what I put in the OnOpen section:

Private Sub Form_Open(Cancel As Integer)
Dim mySQL As String
Dim myDB As DAO.Database
Dim mySet As DAO.Recordset
Dim numRecords As Integer

varSQL = "Select * from Main"

Set myDB = CurrentDb
Set mySet = myDB.OpenRecordset(varSQL)

If mySet.BOF = True Then
'there are no records in Main - so return 0
numRecords = 0
Else
mySet.MoveLast
numRecords = mySet.RecordCount
End If
End Sub


-PR

"Klatuu" wrote:

There is a fairly simple solution for your problem. You could use two user
defined database properties to control it. One property would be the
installed date. When the user first opens the database, check for the
existance of the property. If it is not found, then set it to the current
date, otherwise, compare the current date to installed date.

That does not handle someone resetting the system clock, but there is a
sneaky way to deal with that as well. Use another database property that
will be Last Opened Date. After a user opens the database and you complete
the comparisons above, check to see if the system date is prior to the Last
Opened Date. That will tell you if the user has set the clock back. Then in
the UnLoad event of the form, update the Last Opend date to the current date.
--
Dave Hargis, Microsoft Access MVP


"PaleRider" wrote:

I think I have a different solution. I'll post back with results.

-PR

"PaleRider" wrote:

Hi again,

I have code that prevents the use of a form after a certain amount of days.
What I didn't consider is someone just changing the date on the computer.
Now, I have to figure out how to handle that otherwise it's a mute point.
The code I have in place so far has flaws that can be exploited. Is there a
way to allow someone limited use of database for a certain time frame, then
disable it after that?

Here's the code I have so far which allows use for 14 days, but as mentioned
before it can be exploited by just changing the system date:

Private Sub Form_Open(Cancel As Integer)
Dim myDate As Date
myDate = #6/2/2009#

If DateDiff("d", myDate, Date) >= 14 Then
MsgBox "Your 7 day evaluation for this database has expired."
Cancel = True
End If

End Sub

-PR
.



Relevant Pages

  • Re: Modules not Known
    ... Dim pCode$ ... Dim pCodeModule As CodeModule ... Private Sub VBIDEReference() ... Option Compare Database ...
    (comp.databases.ms-access)
  • Re: populate subform after update
    ... Private Sub Form_AfterUpdate ... Dim db As Database ... 'Establish connection to current database ... tblitems does have a yes/no field for active items. ...
    (microsoft.public.access.modulesdaovba)
  • Re: populate subform after update
    ... Private Sub Form_AfterInsert ... Dim db As Database ... Dim LSQL As String ... 'Establish connection to current database ...
    (microsoft.public.access.modulesdaovba)
  • RE: I didnt think of this
    ... defined database properties to control it. ... When the user first opens the database, ... Private Sub Form_Open ... Dim myDate As Date ...
    (microsoft.public.access.formscoding)
  • Database Properties : Date Created vs DateCreated
    ... I was trying to get my database propeties using VBA Code as follow: ... Dim fs, f, s ... zDateModified is not the same when I check through File> Database Properties ... Database Properties when I click File> Database Properties> General? ...
    (microsoft.public.access.tablesdbdesign)