>>The TOP clause must have GROUP BY. Which I added in the subquery but it still gives me an error.
>
>I believe that is misinformation. I've never used it that way.
>
>Looks like you will have to create a user-defined function to solve your problem until VFP9 gets here.
>
>
>select KEYFIELD, CUST_ID, ORD_DATE, ORD_TIME ;
>from ORDERTABLE ;
>where KEYFIELD == GetLatestOrderKey(CUST_ID) ;
>order by CUSTOMER
>
>procedure GetLatestOrderKey
>lparameter tcCUST_ID
>local array laKeys[1]
>select top 1 KEYFIELD from ORDERTABLE ;
>where CUST_ID == tcCUST_ID ;
>order by ORD_DATE, ORD_TIME descending ;
>into array laKeys
>return laKeys[1]
>
>
>I tested this.
>
>>Thank you for your help.
>
>Always glad to pay back for all the good help I get here.
>
>Peter
Peter,
Thank you very much again for your help.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham