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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting using EVEN/ODD

Status
Not open for further replies.

rdsatx

MIS
Oct 28, 2004
2
US
OK here's my situation.

Table 1 lists PANELS with 'HORIZ' field with a value of either Y or N.

Table 2 lists CIRCUITS for each PANEL. Each CIRCUIT is sequentially numbered 1-42 in FIELD A below.

FIELD A CIRCUIT FIELD B

1 X 1
2 XX 4
3 XXX 2
4 XXXX 5
5 XXXXXX 3

I want to sort CIRCUITS based on the HORIZ field, where if HORIZ = "Y", I want CIRCUITS sorted by FIELD A ascending. However, if HORIZ = "N", I want CIRCUITS sorted by FIELD B ascending, where odd-numbered CIRCUITS will be listed first. How can I do this in a query?

Thanks in advance.


 
It is unclear how table 1 is related to table 2. You state "I want CIRCUITS sorted by FIELD B ascending, where odd-numbered CIRCUITS will be listed first". Is CIRCUITS a field or table or query or what? I also don't see a field HORIZ in your sample of data.

Duane
MS Access MVP
[green]Ask a great question, get a great answer.[/green]
[red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
The basic idea:
ORDER BY IIf(HORIZ = "Y", FieldA, FieldB)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the replies. PHV, I followed your tip and it worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top