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 - =day1time + day2time + day3time
the following formulas add up but dont ignore the empty spaces. needs to be modified - 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: - TotalTime: Format$(Nz(CDate([Day1time]))+Nz(CDate([Day2time]))+Nz(CDate([Day3time])),"hh:nn:ss")
i get the Day1-3 times using the following formula - Day1Time: Nz(Format([Day2]-[Day1],"hh:nn:ss")) etc etc
Should i take this query to a form datasheet?
any suggestions
9 6233
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: -
SELECT PersonTimes.id
-
, PersonTimes.Fname
-
, PersonTimes.LastName
-
, PersonTimes.Day1Time
-
, PersonTimes.Day2Time
-
, PersonTimes.Day3Time
-
, Format(CDate([Day1Time]+[Day2Time]+[day3Time])/(60*60*24),"hh:nn:ss") AS TotTime
-
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
ADezii 8,834
Recognized Expert Expert
It appears to work well in the following context (Attachment):
Let me attach the problem
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?
sorry its the conversion to 2003 that did that
Rt_StageTotal1Q
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. - SELECT Format$(IIf(IsNull([Day1Time]),0,CDate([Day1Time]))
-
+IIf(IsNull([Day2]-[Day1]),0,CDate([Day2]-[Day1]))
-
+IIf(IsNull([Day3]-[Day2]),0,CDate([Day3]-[Day2])),"hh:nn:ss") AS T1T,
-
Nz(Format([Day2]-[Day1],"hh:nn:ss")) AS Day2Time, Cyclist.Name,
-
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
-
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
-
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;
Thx mr Adezii; will have a look.
working 100%; you are star - mr Adezii!!
ADezii 8,834
Recognized Expert Expert
Glad we got it working for you.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 :...
|
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...
|
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...
|
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)...
|
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...
| |
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,...
|
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...
|
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...
|
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() {
...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| | |