In the words of fellow MVP, Jeff Boyce, "You have committed spreadsheet". I
would change the table structure so that each appointment created a record in
a separate table.
If you can't change your table structure to be more normalized, you can
create a union query like:
SELECT AddressID, 1 as ApptNum, Appt1 as ApptDate
FROM tblA
WHERE Appt1 Is Not Null
UNION ALL
SELECT AddressID, 2 , Appt2
FROM tblA
WHERE Appt2 Is Not Null
UNION ALL
SELECT AddressID, 3 , Appt3
FROM tblA
WHERE Appt3 Is Not Null
UNION ALL
SELECT AddressID, 4 , Appt4
FROM tblA
WHERE Appt4 Is Not Null
UNION ALL
SELECT AddressID, 5 , Appt5
FROM tblA
WHERE Appt5 Is Not Null;
Then save this query as quniAddressAppts. Create a new query like:
SELECT AddressID, Max(ApptDate) as MaxDate
FROM quniAddressAppts
GROUP BY AddressID;

Signature
Duane Hookom
Microsoft Access MVP
> Hi,
>
[quoted text clipped - 21 lines]
>
> Thanks
JezLisle - 24 Apr 2008 15:15 GMT
Thanks for the reply.
The problem is that I didnt build the databse, thats someone else handy work.
I can only report from it, I havent seen that problem before as all other DB
I worked on have done as we would think they are built
>In the words of fellow MVP, Jeff Boyce, "You have committed spreadsheet". I
>would change the table structure so that each appointment created a record in
[quoted text clipped - 33 lines]
>>
>> Thanks
Duane Hookom - 24 Apr 2008 17:27 GMT
Were you able to implement my suggestion?

Signature
Duane Hookom
Microsoft Access MVP
> Thanks for the reply.
>
[quoted text clipped - 39 lines]
> >>
> >> Thanks
JezLisle - 25 Apr 2008 13:23 GMT
Yeah I tried it and works just fine. Thanks...
>Were you able to implement my suggestion?
>> Thanks for the reply.
>>
>[quoted text clipped - 39 lines]
>> >>
>> >> Thanks
John Spencer - 24 Apr 2008 18:09 GMT
Here is a function that I have built that will get the max date. Sometimes
you just gotta do what you gotta do and work around the bad data structure.
You can use it in as follows. You are limited to a maximum of 29 arguments
when you use this function in a query.
Field: LastDate: fGetRowMax(Appt1,Appt2, Appt3, Appt4, Appt5)
'------------- Code Starts --------------
'Version to handle dates, numbers, or text values
Public Function fGetRowMax(ParamArray Values()) As Variant
'John Spencer UMBC CHPDM
'Last Update: April 5, 2000
'Returns the Maximum of a group of values passed to it.
'Handles text, date, & number fields.
Dim i As Long, vMax As Variant
vMax = Null
For i = LBound(Values) To UBound(Values)
If IsNull(Values(i)) = False Then
If Values(i) <= vMax Then
Else
vMax = Values(i)
End If
End If
Next
fGetRowMax = vMax
End Function
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
> Thanks for the reply.
>
[quoted text clipped - 38 lines]
>> [quoted text clipped - 21 lines]
>>> Thanks