Expiry date for Demo Data Base

G

Guest

I have written a module for restriction after a certain date as follows. I
also have a Autoexec Macro, but the code appears to be missing something, as
i get the following error mesage "Visual Basic module contains syntax error"

Any help would be appreciated
MODULE CODE:

Option Compare Database
Dim db As Database
Dim rs As DAO.Recordset
Dim x As Integer
Dim y As Integer

Function StartUp()
On Error GoTo Err_ProcedureName

Set db = CurrentDb
Set rs = db.OpenRecordset("tblDateFlagged", dbOpenDynaset)

If rs.EOF = False Then
rs.MoveLast
If rs.Fields("FlagDate") = True Then
MsgBox "This Database has expired. Please contact vendor to
purchase.", vbOKOnly, "Serious Warning"
DoCmd.Quit
End If

If Date > rs.Fields("MeDate") Then
MsgBox "You have set your date forward and the database will be
closed to continue to use the rest of your 30 days reset your date to the
current date and reopen the database", vbOKOnly, "Serious Warning"
DoCmd.Quit
End If

rs.MoveFirst
If Date < rs.Fields("MeDate") Then
MsgBox "You have set your date back and the database will be closed
to continue to use the rest of your 30 days reset your date to the current
date and reopen the database", vbOKOnly, "Serious Warning"
DoCmd.Quit
End If

Else

If rs.BOF = True Then
y = 0

Do Until x = 30
x = rs.RecordCount

rs.AddNew
rs.Fields("MeDate") = Date + y
rs.Update
y = y + 1
Loop
End If
End If
UpdateTable

Exit_ProcedureName:
Exit Function

Err_ProcedureName:
MsgBox Err.Description, vbOKOnly + vbCritical, "Function Start Up"
Resume Exit_ProcedureName

End Function
Function UpdateTable()
On Error GoTo Err_ProcedureName

Set db = CurrentDb
Set rs = db.OpenRecordset("tblDateFlagged", dbOpenDynaset)

If rs.BOF = False Then
rs.MoveFirst

Do While rs.Fields("MeDate") <= Date
rs.Edit
rs.Fields("FlagDate") = True
rs.Update
rs.MoveNext
Loop

End If

Exit_ProcedureName:
Exit Function

Err_ProcedureName:
MsgBox Err.Description, vbOKOnly + vbCritical, "Function Update Table"
Resume Exit_ProcedureName
End Function

AUTOEXEC CODE MACRO:
Action: Run Code - startup ()
Open Form - Main Menu
 
T

TC

Um: /on what line/?

It's not really fair to expect everyone to wade through that whole lot,
when the line in question has probably been highlighted by the syntax
editor ...

TC
 
J

Jeff Conrad

If I may quote Doug Steele on a past post:Database is a DAO object. By default, both Access 2000 and 2002 use ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.x
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
I have written code for expiry date for a demo data base as follows: The
error occurs as a compile error in this line and I am not sure what is wrong.
Thanks for any help

Dim db as DataBase

<<code snipped>>
 
T

TC

PS. With an expry date method, the people who get the demo next month,
will have a month's less time than those who get it right now (and so
on). Is that actually what you want?

The alternative is to have the database trap the date at which it is
first run. Then give them 'x' days past that date. Then you can burn a
squintillion copies, and each copy works for the same duration of time,
after it has been run for the first time.

HTH,
TC
 
K

Keith

Roger Bell said:
I have written a module for restriction after a certain date as follows.
I
also have a Autoexec Macro, but the code appears to be missing something,
as
i get the following error mesage "Visual Basic module contains syntax
error"

Any help would be appreciated
MODULE CODE:

Option Compare Database
Insert "Option Explicit" here and then re-compile.
Dim db As Database

www.keithwilby.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top