Marc,
Whould this work for you?
SELECT DOS_ID, MAX(Rol_date) AS Rol_date ;
FROM Dossier ;
GROUP BY DOS_ID ;
INTO CURSOR crsMaxRolDate
SELECT Dossier .*, crsMaxRolDate.Rol_date ;
FROM Dossier ;
JOIN crsMaxRolDate ON crsMaxRolDate.DOS_ID = Dossier.DOS_ID ;
INTO CURSOR crsResult
BTW, what's virtual field?
>I have two tables Dossier and Rolhand
>
>I'am trying to get the newest date from table rolhand into dossier. <-- Text in Red
>I'am using virutal field, but i can't get it to work.
>Table: Dossier
>
>*DOS_ID Rol_id Rol_date
>------ -+--------------+------------
>1 05dak-91 21-01-05 <-- this is not working, YET Big Smile
>2 02man-11 01-08-05
>
>
>
>
>Table: Rolhand
>
>tab2_id *DOS_ID Rol_date Name
>-------+----------+------------+----------
>1 1 21-01-05 Marc
>2 1 20-01-05 Chris
>3 2 25-07-05 Denis
>4 2 01-08-05 Walker
>I am using Microsoft Visual FoxPro 8.0, i don't know if i can use SQL/Fox pro code.
>
>I use another virtual vield and this one is working!!
>look_mgr.get_value(dossier.cost_code,'cost.cost_desc')
>
>dossier.cost_code i use to get the vield cost_desc in table cost.
>
>Now i want to use dossier.dos_id to get Rol_date in table rolhand
>
>I tried to use this code
>look_mgr.get_value(dossier.dos_id,'rolhand.rol_date') but i get empty result.
>
>The reason of the is there are more then one vield in the result, that's my guess.
>
>When i put this in a query:
>
>SELECT MAX(Rolhand.rol_datum) AS datum FROM trv_bv!rolhand WHERE Rolhand.dos_id = ( "0000000040" )"
>
>I get one result "04-04-2004" it works!!!! wow!
>
>
>
>But when i put the code in an virtual vield in Microsoft Visual FoxPro 8.0 i don't get any result.
>
>My question for now is: can i use sql/foxpro code in an virtual vield??
>
>Later i tryed this one:
>
>SELECT MAX(Rolhand.rol_datum) AS datum FROM trv_bv!dossier INNER JOIN trv_bv!rolhand ON Dossier.rec_id = Rolhand.dos_id WHERE Rolhand.dos_id = ( "0000000040" ) ORDER BY Dossier.dos_id, Rolhand.rol_datum
>
>No results. But when i type this direct in one query it works fine.
--sb--