You can simply set the DefaultValue property of the control for the date in
the subform to:
Date()
That will insert the current date for any new record in the subform. If you
want the subform to go to the new record automatically then the best place
would I think be the Current event procedure of the main parent form. This
would mean that every time you move to another record in the main form the
subform would immediately go to a new record and the current date would be in
place. This would not actually start to create a new record in the subform;
that would only happen when you add more data into it, so if the user does
not add any more data in the new subform record no new record would be
created when they move on.
What you'd need to do is set focus to the subform and then move to the new
record. To do this you'd refer to the subform control, i.e., the control in
the main parent form which houses the subform, so the code would be along
these lines:
Me.[YourSubformControl].SetFocus
DoCmd.GoToRecord Record:=acNewRec
If you don't want the focus to stay on the subform's new record when you
move to a record in the main form add another line to the above code which
moves the focus back to an appropriate control on the main form, e.g.
Me.[SomeControl].SetFocus
This would mean that the record pointer in the subform would be at its new
record, but the insertion point would be back in whichever control on the
main form you've moved focus to in the above extra line.
Ken Sheridan
Stafford, England
austin said:
Thank you very much for your time and help.
You wouldn't happen to know how to set a subform up so that it starts a new
record with the current day in it every time it is opened?
Ken Sheridan said:
Either of the queries I gave you will do that. The first gives you just the
client and latest date columns per client; the second gives you all the other
columns from the table as well for those rows with the latest date per client.
Paste the SQL I posted into a blank query in SQL view and amend the SQL so
the table and column names match your own (but in the case of the second
query not the aliases CL1 and CL2 which should stay as is), remembering to
wrap any names with spaces in brackets [like this], and it should work.
Ken Sheridan
Stafford, England
austin said:
I'm looking for the query to display a list of all of our clients, and the
last contact date with each.
I might not of phrased my original question well because whenever I change
the settings accordingly, I still see all of the calls for each person
instead of their latest.
:
If you simply want to return the latest contact date per client then group by
client and return the Max contact date:
SELECT Client, MAX(ContactDate) AS LatestContact
FROM CallLog
GROUP BY Client;
If you want to return other columns than that (or those) by which the query
is grouped and the date, e.g. the subject of the call, then use a subquery to
restrict the outer query's return set to the rows with the Max contact date
per client, e.g.
SELECT *
FROM CallLog AS CL1
WHERE ContactDate =
(SELECT MAX(ContactDate)
FROM CallLog AS CL2
WHERE CL2.Client = CL1.Client);
Remember that any table or column names which contain spaces or other
special charcters must be wrapped in brackets [like this].
BTW avoid the FIRST and LAST aggregation operators, which are pretty
pointless. Use operators like MIN, MAX etc which operate on values as the
basis for aggregation.
Ken Sheridan
Stafford, England
:
I have a call log table that has multiple records for each of our clients.
Can you run a query so that it displays the last time (Contact Date) we
spoke to each and every one of our clients?
thanks