A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Compare multiple fields in record



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2004, 02:58 AM
Can
external usenet poster
 
Posts: n/a
Default Compare multiple fields in record


I have 5 different date fields in a record, I need to
compare them to see which date is the most current. Some
fields may be null.

I have a module, then I reference the function from the
module through a query. I get an error "compile error. in
query expression" when I try to run it.

I was going to scrap the module and try to get the result
a different way but my brain is fried and I can not think
of another way to do this.

Any ideas?
  #2  
Old May 29th, 2004, 04:27 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default Compare multiple fields in record

It seems that your data might not be normalized. One method to grab the most
recent date is to create a union query from your table
Select [DateA], "A" as TheDate, Field1, Field2
From tblYourTable
UNION
Select [DateB], "B", Field1, Field2
From tblYourTable
UNION
Select [DateC], "C", Field1, Field2
From tblYourTable
UNION
Select [DateD], "D", Field1, Field2
From tblYourTable
UNION
Select [DateE], "E", Field1, Field2
From tblYourTable;
You can then Select the Max([TheDate]) from the Union query.


--
Duane Hookom
MS Access MVP


"Can" wrote in message
...

I have 5 different date fields in a record, I need to
compare them to see which date is the most current. Some
fields may be null.

I have a module, then I reference the function from the
module through a query. I get an error "compile error. in
query expression" when I try to run it.

I was going to scrap the module and try to get the result
a different way but my brain is fried and I can not think
of another way to do this.

Any ideas?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.