I have a simple access database that holds contacts. My people table has a column named "Last Contact" that is a date value representing the date of last contact. On my main screen I have a form that displays the person's information, including the "Last Contact" date.
I need to build in an alert system that let's users know when it has been longer than 30 days since the last contact date. I have built a simple text box that accomplishes this by displaying the text "30 Days" in big red letters. The name of this text box is "notice."
My problem comes with having this text box only appear when it has been 30 days or more since the "Last Contact" date. I am using the code below:
Sub notice()
Dim dateone As Date
Dim datetwo As Date
Dim days As Integer
Dim notice As Object
dateone = Last_Contact!
datetwo = Date
days = DateDiff("d", dateone, datetwo)
notice = [notice]
If days >= 30 Then
notice.Visible = True
Else
notice.Visible = False
End If
End Sub
When I run this, I get an "Overflow" error. Can someone please assist me with this?
Thank you in advance.
dim Notice as TextBox
and not asObject
? I would also consider naming your VBAnotice
as something other than the textbox name to avoid confusion, and potential issues with the code. – guitarthrower