By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

Datediff

P: n/a
Hi.
I have 3 seperate date fields.

InitialDate
InspDate
ReportDate

I am trying to setup several unbound Text boxes in a form that will give me
days elapsed between these dates. These text boxes act like message boards
to alert the user if the days elapsed have exceeded a certain amount of
days.

Eg1. User populates the InitialDate field with a date. The InspDate and
ReportDate fields are for the moment left empty.
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate
field and current date), the message "INSPECTION OVERDUE" comes up and the
days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days
criteria.

The same goes for the populating of the InspDate field and leaving the
ReportDate field empty. A message in another unbound text box shows if over
6 days have elapsed from when the InspDate has been populated and the
current date.

Any help would be appreciated.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi T23Ij9 (Nice name ..)
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate
field and current date), the message "INSPECTION OVERDUE" comes up and the
days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days
criteria.


I would use two lable controls say LblDaysPassed and LblMessage. For both caption = " "
Then I would use the forms Current-Event to change the caption.

Private Sub Form_Current()
Dim intDaysPassed as Integer
intDaysPassed=DateDiff("d",[InitialDate],Date())
If IsNull(Me!InspDate) then
Me!LblDaysPassed.caption = intDaysPassed
If intDaysPassed >=6 then
Me!LblMessage.caption = "INSPECTION OVERDUE"
Else
Me!LblMessage.caption=""
End if
Else
Me!LblMessage.caption=""
Me!LblDaysPassed.caption = ""
End if
End Sub

Similar for your other ReportDate

--
Hope this helps
Arno R
Nov 13 '05 #2

P: n/a
Under caption in each label i entered ""
I placed the code in the form's current event but then i got a Run time
error '2465'
The error message said that it could not find the field "I" referred to in
the expression.

The expression it was referring to in the debugger was:

intDaysPassed = DateDiff("d", [InitialDate], Date)

For some reason the () in the Currnet Date part is not there ... should
originally read Date()
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate field and current date), the message "INSPECTION OVERDUE" comes up and the days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days criteria.


I would use two lable controls say LblDaysPassed and LblMessage. For both
caption = " "
Then I would use the forms Current-Event to change the caption.

Private Sub Form_Current()
Dim intDaysPassed as Integer
intDaysPassed=DateDiff("d",[InitialDate],Date())
If IsNull(Me!InspDate) then
Me!LblDaysPassed.caption = intDaysPassed
If intDaysPassed >=6 then
Me!LblMessage.caption = "INSPECTION OVERDUE"
Else
Me!LblMessage.caption=""
End if
Else
Me!LblMessage.caption=""
Me!LblDaysPassed.caption = ""
End if
End Sub

Similar for your other ReportDate

--
Hope this helps
Arno R
Nov 13 '05 #3

P: n/a
> Under caption in each label i entered ""

Are your lable controls there ? When I enter "" as a caption my lable is gone ...
Change the caption to "x" and try again please.
For some reason the () in the Currnet Date part is not there ... should
originally read Date()

intDaysPAssed = DateDiff("d", [InitialDate], Date) should work.

Hope this helps
Arno R
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.