Text box on form

R

Rey

Hello All,

I would like to put a text box on my main form that would show the
date of the most current records in a specific table.
 
M

missinglinq via AccessMonster.com

Obviously you have to have a field in the records of your table to hold a
date. Either the creation date, if that's what you want, or the edit date;
whichever fulfills your needs. Then on your main form, a box to display the
date on the most current record. Then place this code in the appropriate sub,
OnLoad perhaps:

YourTextBox = DMax("[CreationDate]", "YourTable")
 
K

Klatuu

If you use the table or query directly and the form is filtered, this could
give incorrect results. It would be better to use the form's recordset:

=DMax("[CreationDate]", Me.Recordset.Name)
 
R

Rey

Obviously you have to have a field in the records of your table to hold a
date. Either the creation date, if that's what you want, or the edit date;
whichever fulfills your needs. Then on your main form, a box to display the
date on the most current record. Then place this code in the appropriate sub,
OnLoad perhaps:

YourTextBox = DMax("[CreationDate]", "YourTable")

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200706/1

Do I put this code in the properties of the form? Do I need put
anything in the properties of the tex box?
 
K

Klatuu

In the Load event of the form.
--
Dave Hargis, Microsoft Access MVP


Rey said:
Obviously you have to have a field in the records of your table to hold a
date. Either the creation date, if that's what you want, or the edit date;
whichever fulfills your needs. Then on your main form, a box to display the
date on the most current record. Then place this code in the appropriate sub,
OnLoad perhaps:

YourTextBox = DMax("[CreationDate]", "YourTable")

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200706/1

Do I put this code in the properties of the form? Do I need put
anything in the properties of the tex box?
 
R

Rey

In the Load event of the form.
--
Dave Hargis, Microsoft Access MVP



Rey said:
Obviously you have to have a field in the records of your table to hold a
date. Either the creation date, if that's what you want, or the edit date;
whichever fulfills your needs. Then on your main form, a box to display the
date on the most current record. Then place this code in the appropriate sub,
OnLoad perhaps:
YourTextBox = DMax("[CreationDate]", "YourTable")
Do I put this code in the properties of the form? Do I need put
anything in the properties of the tex box?- Hide quoted text -

- Show quoted text -

Thanks for all the help!
 
M

missinglinq via AccessMonster.com

"If you use the table or query directly and the form is filtered, this could
give incorrect results. It would be better to use the form's recordset:"

And if the "main form" is a menu form, and there's no recordset open?
 
Top