You can computer the age in a query by creating a calculated field that
calls a user defined function then on the form, bind the textbox to this
field. You can create a calculated control on the form that does the same
thing. It should then recalculate as you go to each record.
In the query, the field would look like:
RecordAge:MyFunction([RecordDateField])
In the form, the textbox's Control Source would be like:
=MyFunction([txtRecordDateTextbox])
For examples for the user defined function, follow this link:
http://www.mvps.org/access/datetime/date0001.htm
You may need to adjust this for the format that you want the result in. If
all you're wanting is a few days at most, then DateDiff() by itself is
probably sufficient and you could skip the user defined function.
Example:
RecordAge:DateDiff("d", [RecordDateField], Date())
or
=DateDiff("d", [txtRecordDateTextbox], Date())
--
Wayne Morgan
MS Access MVP
"wildbill" <we*******@charter.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I'm looking for an example of how to compute an age of a record in a
query and then display that on a form. For example: I have record
that shows it was entered on 8/2/2005. I would like to be able to have
the query return something like "record is 35 days old".
I know I can compute the age via the DateDiff function in VBA but can't
seem to figure out how to change the value in an unbound control on the
form as I scroll through the recordset.
Any suggestions, comments, code-snippets, etc would be appreciated.
Bill W