473,383 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Can I create 'conditional' sorting on report

167 100+
I have 2 columns, Date & Odom which I need to base the sorting on. If the column 'odom' has value of '0', I want to use the 'Date' field to sort the report, if there is a value in the odom column, I want to use 'Odom'. I created a invisible text box on my report called 'txtsortparm' and in the control source I used: =IIF([Odom]=0,[Date],[Odom]). The report is prompting me for a value for this column. Any suggestions on how I can do 'conditional sorting'???

Thanks!
Mar 18 '08 #1
3 4433
Stewart Ross
2,545 Expert Mod 2GB
Hi. Could you explain what you mean when you say 'if the column 'odom' has the value of '0'? If Odom is a field in the table on which you are basing your report you will not be able to sort using the IIF, as you are actually comparing values on a row-by-row basis.

It would be helpful to see some sample data to get a clearer picture of what you are trying to sort upon.

-Stewart
Mar 18 '08 #2
ncsthbell
167 100+
Sorry, here are some more details. I am using a query for my report data source. For each row of data there are columns named 'Odom' and 'TripDate'. I have the sort/grouping on the report set up currently to sort by 'Odom' (this value is the beginning odometer #). I have been asked to change the report so the sort will first check to see if the value of 'Odom' is 0 (no beginning odom exists), if is 0, then they want me to use the 'trip date' to sort the details.
I tried setting up a new column in my query and put the "if" test in the query and set a new field called 'SortBy'. I moved the value of either Odom or TripDate (depending on if Odom was 0) to this new column. Then I put this column on the report as invisible and changed the sorting/grouping on the report to use this value. It did not work.
I hope these details make more sense as to what I am trying to accomplish.
Mar 18 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Thanks for clarifying these points - it really helps with understanding what you are doing. Your approach appears very sound, but not quite complete. You will also have to include a field in your query to group your report on whether you are using Odom or not. Otherwise, sorting is likely to mix the two together without grouping all zero-odometer readings into one group sorted by date value and the other group sorted by odomoeter reading. You could add a simple true/false field for this in your query such as
Expand|Select|Wrap|Line Numbers
  1. UseDateSort: [Odom]=0
Other point is that to sort on a single field correctly I think you should convert your dates to numbers in the IIF for sorting purposes. That way the sort in your subsequent report will sort on numbers only. The IIF would be changed to
Expand|Select|Wrap|Line Numbers
  1. SortBy: IIF([odom]=0, CLng([TripDate]), [Odom])
With this slightly revised SortBy field and a new grouping field of UseDateSort you should use grouping in your report on UseDateSort before sorting on SortBy.

Hope you succeed with this.

-Stewart
Mar 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Trupti | last post by:
Hi, I want to create the crystal report for a text file but i don't want it to be done with ODBC.... But when i tried to do that using Access/Excel(DAO) then it was asking me for the Server...
0
by: Joe Saliba | last post by:
hi, am a beginner on access and sql server so i would like to know plz how to create an auto report on access project based on a view thanks *** Sent via Developersdex...
1
by: Jason via AccessMonster.com | last post by:
I m trying to sort by quaters. I m using a qry as my basis for the report. the qry sums up fields and provides me with toals by qtr. I can not seem to get the sort to work in the report for those...
0
by: Zandile Zulu via .NET 247 | last post by:
Somebody pls help is it possible to create a crystal report in vb.net that looks like an excel worksheet if so how!! pls reply 2me its urgent! -------------------------------- From: Zandile Zulu...
6
by: Peter Herath | last post by:
I want to create a dynamic report using a crosstab query...... pls someone look into my attached example database and help me out to do the report generation.... example is like dis...: there...
1
by: DavidB | last post by:
I have a report that (among other data) lists three different date fields from one of my tables. This is a validation report in that date #1 and date #2 should be earlier than date #3. The report...
0
by: balurajeev | last post by:
Hi friends , I want to create a Crystal report in C# using Parameterised Storred Procedure This is my Stored Procedure ALTER proc . ( @fname varchar(50), @lname varchar(50),
3
by: Rhys Gottwald | last post by:
Hi All, I have a report that is going to have 30 odd fields each containing a number, the number is the wind speed. I want to format the background of the field based on the value of the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.