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
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