Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 Criteria in 1 Query

Status
Not open for further replies.

banks13cu

MIS
Jun 16, 2005
13
US
I need to be able for a Query to take information from column if it is present but if it isn't then take it from a different column. For example...

Table has a Room Number column and a Birthday column. I need the query to sort by Birthday unless the Room Number is present. For query named Room_103 there is a Room Number entered in the table 103 and it pulls that one. But if there isn't a Room Number entered in the table then it defaults on the Birthday and pulls from the table if the Birthday falls between 4/1/2004 and 5/31/2004. However, if there birthday is 4/2/2004, but you enter 104 in the Room Number column of the table it takes them out of Room_103 query and puts them into Room_104 query.

If you have any ideas, please help me...

thanks
 
Can you create a sortby field in your query which would do this for you?

sortby: iif(RoomNum is null,birthday,roomnum)

This would generate a field with the values you want, and just sort on that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top