This is my first code I've tried to write so forgive basic errors please. I've Searched this forum for examples and issues but all the answers havent worked and I'm not sure if Im even in the ballpark of writing this correctly.
I have a table ,tblVehicles, with vehicle data. When I open my database, (Step One) I want a message box to open if the Registration date in the table has passed today's date. I want to know that a vehicle Registration has expired.
(Step Two) Once i get that, i want to edit code to let me know when it will expire within 30 days .
Im asking for help to get Step One only. I have commented out in the code where i get my error.
I have a table ,tblVehicles, with vehicle data. When I open my database, (Step One) I want a message box to open if the Registration date in the table has passed today's date. I want to know that a vehicle Registration has expired.
(Step Two) Once i get that, i want to edit code to let me know when it will expire within 30 days .
Im asking for help to get Step One only. I have commented out in the code where i get my error.
Code:
Function AutoExec2()
Dim db As Database
Dim rs As Recordset
Dim RegistrationDate As Date
Set db = CurrentDb
Set rs = db.OpenRecordset("tblVehicles")
rs!RegistrationDate = "RegistrationDate"
'The Dlookup is where i get an error "Compile Error: Syntax error"
Dlookup("RegistrationDate", "tblVehicles", "RegistrationDate = #Now()#")
If "RegistrationDate" <= Now() Then
DoCmd.OpenForm "MessageBoxVehReg", acNormal, "", "", , acNormal
Else
DoCmd.OpenForm "MessageBoxVehRegUpdated",acNormal,"","", ,acnormal
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Last edited: