Query to get Latest Status

music_al

Registered User.
Local time
Today, 19:40
Joined
Nov 23, 2007
Messages
200
Hi

I have an intermediate/junction table that records the status of a job candidate and the date that the status was reached. The logic is that the most recent date/time is the current status. So, I'd like to build a query and then pass this to a field in the Candidate table.

The intermediate/junction table is made up like this

Candidate_Status_ID
Candidate_ID
Status_ID
Status_Date

Ive created a simple query and in the Status_Date field Ive used the MAX function but its still showing all the dates relating to that candidate. See the attachment

Candidate Status.PNG

How do I then pass that STATUS value (not the date) to a text box ?
 
Remove the first and third fields from your query so you just have CandidateID and max date.
 
Thank you.

And how do I then pass the status to a text box on the parent form ?
 
You could set the textbox control source using your query ...
or scrap the query and use a Dlookup based on the table with suitable filter criteria.
 
I set the Source for the Textbox as the field in the query...

=[qry_Candidate_Status2]![Candidate_Status_Long]

but when I load the form the Textbox just shows...

#Name?
 
Ummm ...not like that

Try something like one of these for the control source instead

Code:
= DLookup("MaxOfStatus_Date","tblCandidate_Status", "Candidate_ID = " & Me.Candidate_ID)

OR create your query qryCandidate_Status as
Code:
SELECT Max(Status_Date) AS MaxDate FROM tblCandidate_Status WHERE Candidate_ID = Forms!YourFormName.Candidate_ID

then use this as your control source
Code:
= DLookup("MaxDate","qryCandidate_Status")
 

Users who are viewing this thread

Back
Top Bottom