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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make database work for some period of time?

Status
Not open for further replies.

cikul

Programmer
Aug 25, 2001
12
0
0
EU
I need some kind of shareware version of my database.
I want to make database work for exmpl. for 7 days and everytime you start the database it says "You have # days left" and after 7 days to stop working, also not to accept F5 key for bypassing startup options. How can I do this?
 
I accomplished this with 3rd party software. When I contacted MS about any help with this, they told me that they did not offer any code to allow demo or numbered day versions, so I turned to 3rd party sw.
 
What kind of 3rd party software?
 
I use this in my switchboards on load.

Private Sub Form_Load()
'***********************************************************
'This code will shutdown database after a specified number of records have been written.
'Assign the dbs.OpenRecordset("???????????") to a table that controls when you shut down the database
'Make sure the table you select is used in every record
'***********************************************************

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim intCount As Integer

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("your table")
With rst
If rst.RecordCount > 0 Then
intCount = rst.RecordCount
End If
If intCount >= 500 Then
MsgBox "The demo version of this database has reached its user limit. You may contact ??? for more information."
DoCmd.Quit
End If
End With
Set rst = Nothing
Set dbs = Nothing

End Sub

It sees how many records are in the table and if it is more than you allow shuts down. Pick a table that is used with every record then put this in an MDE so they can't modify things.

Hope it helps!

Zorro
 
How about creating a table with two fields called FirstRunDate & ExtinctionDate or something. You can then write some code which executes on startup & checks to see if this table has a record in it. If it does not, it can append the current date & time, to the FirstRunDate field, & use the datedifference function to work out the date in a specified time. If the table already has a value, you can check if the specified date has passed. If it has the program can quit, otherwise it can pop a message box & continue. I will try to work out the code & post it below..... James Goodman
j.goodman00@btinternet.com
 
Create a table called tblDate, & set it to system, hidden. That way it will be a little harder to find, although I would recommend making it into an MDE & not allowing the users access to the database window. Within the table, two fields, called InitialDate & ExpiryDate.



Sub CheckDates()
dim db as database, rst as recordset, dteInitial as date dteExpire as date, DaysRemaining as integer
set db = currentdb
rst = db.openrecordset (SELECT * FROM tblDate)
if rst.recordcount > 0 then 'If a record exists, the sub has executed previously
dteexpire = rst!expirydate
if datediff(&quot;d&quot;, Date, dteExpire) < 1 then 'Will be accurate to the nearest day
msgbox &quot;The trial period has expired&quot;
docmd.quit
else
DaysRemaining = datediff(&quot;d&quot;, date, dteexpire)
msgbox &quot;You have &quot; & daysremaining & &quot; days remaining&quot; 'Tell the user how many days remain in their trial
endif
else
rst.addnew 'You might need to add an rst.edit before this line
rst!dteinitial = date
rst!dteexpire = DateAdd(&quot;d&quot;, 7, dteinitial)
rst.update
endif

HTH

James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top