473,484 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to ignore an #Error in a query field you are sorting, descending?

547 Contributor
When i try and add up 3 fields in a query and 1 field is blank, i a get #Error.(due to complicated string problems)

This is fine, but now i want to sort the rest of the records that do add up, and then ignore the one in this descending query, that has an empty field preventing it from been added up.See screen capture pics.
I will be happy just to sort those with totals, as an athlete have to finish all 3 days to be in contention for the overall prize.I you finish only 1 or 2 days, you are disqualified anyway and the total time will be ignored.

fields to add up are
Expand|Select|Wrap|Line Numbers
  1. =day1time + day2time + day3time
the following formulas add up but dont ignore the empty spaces. needs to be modified
Expand|Select|Wrap|Line Numbers
  1. TT: Format$(IIf(IsNull([Day1Time]),0,CDate([Day1Time]))+IIf(IsNull([Day2Time]),0,CDate([Day2Time]))+IIf(IsNull([Day3Time]),0,CDate([Day3Time])),"hh:nn:ss")
have also tried:
Expand|Select|Wrap|Line Numbers
  1. TotalTime: Format$(Nz(CDate([Day1time]))+Nz(CDate([Day2time]))+Nz(CDate([Day3time])),"hh:nn:ss")
i get the Day1-3 times using the following formula
Expand|Select|Wrap|Line Numbers
  1. Day1Time: Nz(Format([Day2]-[Day1],"hh:nn:ss")) etc etc
Should i take this query to a form datasheet?
any suggestions
Attached Images
File Type: jpg stagetotaltime_error.jpg (31.6 KB, 308 views)
File Type: jpg stagetotaltime_error2.jpg (51.1 KB, 545 views)
Dec 5 '10 #1
9 6233
orangeCat
83 New Member
You haven't shown how your fields are defined.
Here is a sample using the following data.

Table: PersonTime
Fields:
ID autonumber KEY
FName text
LastName text
Day1Time number long integer
Day2Time number long integer
Day3Time number long integer

My intent would be to store the Times in Seconds
and calculate the results.

The data, including a time of 0, are
1
Joe
Smith
10
78
0 <-----) time recorded

2
Tom
Jones
74
127
60
The query:
Expand|Select|Wrap|Line Numbers
  1. SELECT PersonTimes.id
  2. , PersonTimes.Fname
  3. , PersonTimes.LastName
  4. , PersonTimes.Day1Time
  5. , PersonTimes.Day2Time
  6. , PersonTimes.Day3Time
  7. , Format(CDate([Day1Time]+[Day2Time]+[day3Time])/(60*60*24),"hh:nn:ss") AS TotTime
  8. FROM PersonTimes;
The rationale is to sum the number of seconds in the calculation; convert it to a date by
dividing the total seconds by
(seconds per minute *minutes per hour * hours per day)
to get days and to format as hh:nn:ss
Attached Images
File Type: jpg Bytes_Seconds.jpg (15.3 KB, 215 views)
File Type: jpg Bytes_SeconsQry.jpg (26.0 KB, 417 views)
Dec 5 '10 #2
ADezii
8,834 Recognized Expert Expert
It appears to work well in the following context (Attachment):
Attached Files
File Type: zip Times.zip (13.6 KB, 96 views)
Dec 5 '10 #3
neelsfer
547 Contributor
Let me attach the problem
Attached Files
File Type: zip timesproblem2003.zip (43.2 KB, 80 views)
Dec 6 '10 #4
ADezii
8,834 Recognized Expert Expert
There is no Code attached to the Click() Event of the Command Button, what Query is causing the problem?
Dec 6 '10 #5
neelsfer
547 Contributor
sorry its the conversion to 2003 that did that
Rt_StageTotal1Q
Dec 6 '10 #6
ADezii
8,834 Recognized Expert Expert
I do believe that the problem lies in the [T1T] Calculated Field (RT_StageTotal1Q)in that it explicitly refers to the [Day2Time] and [Day3Time] Calculated Fields directly. I've substituted the Expressions contained within those Referenced Calculated Fields, and I do believe that it solved the problem. I'll post the revised SQL below as well as the Revised Attachment.
Expand|Select|Wrap|Line Numbers
  1. SELECT Format$(IIf(IsNull([Day1Time]),0,CDate([Day1Time]))
  2. +IIf(IsNull([Day2]-[Day1]),0,CDate([Day2]-[Day1]))
  3. +IIf(IsNull([Day3]-[Day2]),0,CDate([Day3]-[Day2])),"hh:nn:ss") AS T1T, 
  4. Nz(Format([Day2]-[Day1],"hh:nn:ss")) AS Day2Time, Cyclist.Name, 
  5. Nz(Format([Day3]-[Day2],"hh:nn:ss")) AS Day3Time, Cyclist.Surname, Cyclist.Gender, RaceEntry.RaceNo, RaceEntry.IDNo, Rt_Stage1TimesQ.Day1Time, Rt_Stage1TimesQ.ShortMultidayName, Rt_Stage1TimesQ.MultidayStart, Rt_Stage1TimesQ.Day1, Rt_Stage2TimesQ.Day2, Rt_Stage3TimesQ.Day3
  6. FROM (((RaceEntry LEFT JOIN Rt_Stage1TimesQ ON RaceEntry.IDNo = Rt_Stage1TimesQ.IDNo) LEFT JOIN Rt_Stage2TimesQ ON RaceEntry.IDNo = Rt_Stage2TimesQ.IDNo) LEFT JOIN Rt_Stage3TimesQ ON RaceEntry.IDNo = Rt_Stage3TimesQ.IDNo) INNER JOIN Cyclist ON RaceEntry.IDNo = Cyclist.IDNo
  7. GROUP BY Nz(Format([Day2]-[Day1],"hh:nn:ss")), Cyclist.Name, Nz(Format([Day3]-[Day2],"hh:nn:ss")), Cyclist.Surname, Cyclist.Gender, RaceEntry.RaceNo, RaceEntry.IDNo, Rt_Stage1TimesQ.Day1Time, Rt_Stage1TimesQ.ShortMultidayName, Rt_Stage1TimesQ.MultidayStart, Rt_Stage1TimesQ.Day1, Rt_Stage2TimesQ.Day2, Rt_Stage3TimesQ.Day3;
Attached Files
File Type: zip timesproblem2003_2.zip (50.8 KB, 89 views)
Dec 6 '10 #7
neelsfer
547 Contributor
Thx mr Adezii; will have a look.
Dec 6 '10 #8
neelsfer
547 Contributor
working 100%; you are star - mr Adezii!!
Dec 6 '10 #9
ADezii
8,834 Recognized Expert Expert
Glad we got it working for you.
Dec 6 '10 #10

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

Similar topics

0
714
by: DotNetJunkies User | last post by:
I have to deserialize an XML document to objects and then serialize it back to XML to pass to the stored proc. I am attaching partial code. After this , I also have to serialize Here is the XML :...
11
2050
by: MLH | last post by:
I have a query field... Description: & "2-tone" When I run it, the output in that field is empty. If I change the name to MyDescription - it works fine. I noticed the query field has a...
2
1361
by: visionstate | last post by:
Hi there, Is there a way of searching a sub-form (reading from a query) without writing what is exactly contained in the query field. For example if I had a 'Finance Manager' in the query but just...
1
4733
by: chitara | last post by:
is there any posibility to block mysql port or someting? I am getting "Error ,query failed" during adding any data through the admin panel of that website:-( same softwares(php, mysql and IIS)...
5
6451
by: jaishu | last post by:
Hi , I am using a form based on a query. The form is locked and the fields are not editable, but when i just tried typing something, the contents on the form didnt change, but when i closed and...
8
1800
by: MLH | last post by:
Sometimes it works and sometimes it crashes. If I want "Today is " & Date$ & "." to appear in a query field, why might it work sometimes and not others? Would I be better to call a FN? Say,...
4
1839
by: rajtalent | last post by:
hi all, I want to sort the colum when clicks the columnheader using vb.net 2005 .But i receive the following error "Error 1 Overload resolution failed because no accessible 'New' accepts...
1
4139
by: padmaneha | last post by:
Select distinct b.contributor, blogaddress,count(b.contentid) RecipeCount,isnull(c.cnt,0) Other from weblogs.dbo.blogentries b left outer join (select contributor , count(*) cnt from...
11
3226
by: hgreenesmith | last post by:
Hi, I'm working on a select statement to retrieve data, which I know(data exists) is in the MySQL DB. Here is the part I'm working on: function funGetRecipeIngredientsAsTable() { ...
2
1974
by: JaketheSnake27 | last post by:
I'm trying to define a field in a query using an expression. Part of that expression involves using public variables. First of all, is it possible to use variables in a query field? And if it is,...
0
7082
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6953
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7144
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6813
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7214
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3046
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1359
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
235
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.