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