finding last yes.

  • Thread starter Salomon Turgman
  • Start date
S

Salomon Turgman

In one of my tables I have a date field and a gym field which is yes/no
field. In the form for this table I want to display in a textbox the number
of days since the last date were the gym field was yes. Any ideas because I
have none...
Thanks
 
A

Allen Browne

In the Control Source of the text box, use DMax() to get the last date, and
DateDiff() to calculate how long ago that was:

=DateDiff("d", DMax("[MyDate]", "[MyTable]", "[GymField] = True"), Date())
 
S

Salomon Turgman

Im having trouble using the DMax function. Do I need the brackets and
quotations? MyDate would be the name of the date field? MyTable would be
the table name? do I need to put the last True in Quotes?

Thanks
Allen Browne said:
In the Control Source of the text box, use DMax() to get the last date, and
DateDiff() to calculate how long ago that was:

=DateDiff("d", DMax("[MyDate]", "[MyTable]", "[GymField] = True"), Date())

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Salomon Turgman said:
In one of my tables I have a date field and a gym field which is yes/no
field. In the form for this table I want to display in a textbox the number
of days since the last date were the gym field was yes. Any ideas
because
I
have none...
Thanks
 
A

Allen Browne

Have assumed the table "MyTable", has fields:
MyDate Date/Time
GymField Yes/No

If GymField is a Text-type field, you need the quotes. Otherwise no.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Salomon Turgman said:
Im having trouble using the DMax function. Do I need the brackets and
quotations? MyDate would be the name of the date field? MyTable would be
the table name? do I need to put the last True in Quotes?

Thanks
Allen Browne said:
In the Control Source of the text box, use DMax() to get the last date, and
DateDiff() to calculate how long ago that was:

=DateDiff("d", DMax("[MyDate]", "[MyTable]", "[GymField] = True"), Date())

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Salomon Turgman said:
In one of my tables I have a date field and a gym field which is yes/no
field. In the form for this table I want to display in a textbox the number
of days since the last date were the gym field was yes. Any ideas
because
I
have none...
Thanks
 
S

Salomon Turgman

Thank you very much my friend. It works perfectly!!!
Allen Browne said:
Have assumed the table "MyTable", has fields:
MyDate Date/Time
GymField Yes/No

If GymField is a Text-type field, you need the quotes. Otherwise no.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Salomon Turgman said:
Im having trouble using the DMax function. Do I need the brackets and
quotations? MyDate would be the name of the date field? MyTable would be
the table name? do I need to put the last True in Quotes?

Thanks
Allen Browne said:
In the Control Source of the text box, use DMax() to get the last
date,
and
DateDiff() to calculate how long ago that was:

=DateDiff("d", DMax("[MyDate]", "[MyTable]", "[GymField] = True"), Date())

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

In one of my tables I have a date field and a gym field which is yes/no
field. In the form for this table I want to display in a textbox the
number
of days since the last date were the gym field was yes. Any ideas because
I
have none...
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top