Calculate # of days since last visit on a subform

  • Thread starter Thread starter mma40
  • Start date Start date
M

mma40

I have a database of people with the information on a main form. I
need to have a field that shows the number of days since last visit
where the the subform has all the dates (as individual records) that
the person visited. I am not sure if I need to sort the subform
records either. Any help would be greatly appreciated.
 
Presumably you have 2 table: the main form bound to a Client table with a
ClientID primary key, and the subform bound to a Visit table that has a
VisitDate field and a ClientID field that indicates which client it was.

If so, you can put an expression such as this into the Control Source of a
text box on the main form to show the person's most recent visit date:
=DMax("VisitDate", "VisitTable", "ClientID = " & Nz([ClientID],0))

For more help on how to build the 3rd argument for these domain aggregate
functions, see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html
 
Awesome, it worked! I am just learning this stuff. Could you
recommend a book or webpage that could teach me the basics like the
DMax, Dlookup, etc. ?
 
I need to evaluate if LastVisited Field is equal to today with an if
statement but can't get it to work. the Field is calculated as
=DMax("VisitDate", "VisitTable", "ClientID = " & Nz([ClientID],0)).
Any ideas?
 
Allen,

Is there a way to update this calculated field (LastVisited) on the
Main form when a subform (UserDates) record is deleted or edited? I
have tried several variations from threads but nothing is working.

Thanks
 
Back
Top