Text box based on date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Something is wrong, and i know it's simple.

Here is my code:

''' Determining if the Certificate has expired '''
Dim CurrentDate As Date

CertDate = Me.Text84
If CertDate = "" Then
Me.Text203 = ""
Else
Me.Text203 = DateAdd("d", 365, CertDate)
End If

If CurrentDate < Me.Text203 Then
Me.Text201 = "Certificate has EXPIRED!"
End If

If CurrentDate > Me.Text203 Then
Me.Text201 = ""
End If


Here is what i need.

I want some text to tell me "Certificate has EXPIRED!" if the certificate is
past the current date.

And do nothing in the text box if it the date is not past the current date.

Certdate = Date entered on the form of when the cert date is.
The cert expires 365 days after that.

I started with this:

If CurrentDate < Me.Text203 Then
Me.Text201 = "Certificate has EXPIRED!"
else
Me.Text201 = ""
End If

But, it produced the opposite result.

Thanks.
 
I can't see in your code where you assign a date value to the CurrentDate
variable.
Instead you assign a value to CertDate that I can't see where you declare it
 
Well, I don't see anywhere where CurrentDate gets set to the current date.
You have to set it, like this:
CurrentDate= Date
(just "diming" it to a date type doesn't set its value, it just sets it's
type)
or, you could just use the word Date for the current date without having to
define any variables.
Also, you should really give descriptive names to your texboxes rather than
text84. it will make things a lot easier.
hope this helps
-John
 
haha...see, i told i am missing something very simple. I forgot about the
basics.

I will change the names to make more sense, i was just trying to get it too
work first.

Thanks much!
 
Back
Top