473,799 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In expression builder- Sum Top 3

38 New Member
Access 2000, I am trying to add a "Summed" total to a report (in a grouped footer section). But I only want to sum the top 3 items. I know how to write this in sql but it seems I can't get a to a sql expression box from the report view/text box. I can get to the text box properties but that only allows me to open up the expression builder. So is there a way to sum the top 3 in expression builder?

Is there way to nest two different functions in 1 expression?

Thanks for your help!
Jul 14 '07
18 4428
NeoPa
32,579 Recognized Expert Moderator MVP
NeoPa/ADezii,
I may be wrong or misunderstand what is being asked....but why can't DSum be used to obtain totals over the domains for which the Sum can't be computed? I have seen sum, and dsum as alias in the same select statement.
DSum(), has two problems :
  1. How to tell it which three to select for summing.
  2. Efficiency. SQL has a built-in optimiser. Essentially you are running a mini-query every time you run the DSum(). That would be for every record in the outer query. The overhead when using Sum() on a query linked into the main query using the FROM clause is a small fraction of this, except for very low record queries.
PS. ADezii, I haven't forgotten your posts, but will need to find a little time later to give them the attention they deserve.
Jul 16 '07 #11
NeoPa
32,579 Recognized Expert Moderator MVP
Race Number 10 will indicate the 10 mile race. So in the form when entering time I have the following race number options: 1,2,3,4,5,6,7,8 and 10.
Can you confirm that the Race table will only have the nine races in it then (always)?
Jul 16 '07 #12
ADezii
8,834 Recognized Expert Expert
Well that's not what I was hoping to hear. I am trying to create a database that stores the results of a progressive marathon. There are 8) 4 mile lengths and a 10 mile length. The marathon results are the 3 fastest times of the 8 (or how ever many they did, they don't have to do all 8 legs) and the 10 mile leg added together.

I have been trying to figure out what is the easiest way to do this. They want several types of reports such as an individual runner with all of their race legs and then their marathon total. Can I create a sql query that sums the top 3 and adds the 10 mile race and then build a report from that query? I would think yes but I am not sure how to write the query that would sum the top three for each individual runner and not just the top3 of ALL the runners. Any suggestions there?

My tables:

Runner:
BibNum (number) linked to race bibnum
FirstName
LastName
Sex
Age

Race:
BibNum (number)
RaceNum (number)
Minutes (number)
Seconds (number)

They also want to create a report that lists all the runners by sex then age for each individual race and over all marathon scores. I have attempted to do this numerous ways and in a couple different languages and this stupid sum the top 3 is the killer.

Any suggestions for me?

Thanks!
I think I have found a viable, and efficient, solution to your dilemma. The solution involves the creation of an Unbound Sub-Report in the Group Footer Section of the Main Report. The underlying Data Source for this Sub-Form would be a Table whose Records would be dynamically created prior to the actual Report opening. A Public Function would calculate the sum of the 3 fastest 4-mile times then add the 10-mile time for each runner. Once this data is calculated, it would write it to the previously mentioned Table and sort the data with the fastest overall times listed first. When the Main Report opens, this Unbound, independent Sub-Report would list all the runners by First and Last Names along with their calculated Marathon Times with the fastest time being listed first. All logic and calculations are performed within the Public Function. If you wish to go ahead with this approach, please let me know, and please be 100% sure that this is want you want to do since this will involve several hours to actually get this logic in code. I don't mind spending the time, but I would like to be sure that the end result is what you actually want and that it will be used. If you do agree to this, there is additional information that I would need along with sample Marathon data. I don't need a decision right away, as a matter of fact someone else may come up with a better solution, but if you do decide to go this route, I'm available to assist you.
Jul 16 '07 #13
NeoPa
32,579 Recognized Expert Moderator MVP
Still haven't forgotten the replies due to you ADezii and still pushed for time ATM.
What I'm looking at for this though, is a solution in SQL that a report can be built on. Just waiting for OP's confirmation.
Jul 16 '07 #14
ADezii
8,834 Recognized Expert Expert
Still haven't forgotten the replies due to you ADezii and still pushed for time ATM.
What I'm looking at for this though, is a solution in SQL that a report can be built on. Just waiting for OP's confirmation.
I completely understand, NeoPa. Interesting problem, the thorn in the side is the TOP 3 fastest times per runner and not overall, as well as implementing the solution in a Report Footer. I'm pretty sure I can devise a solution as described in the previous Post but I'm just laying back until someone comes up with a better solution or the OP wants to take this approach. To your credit, I figure that if you can't come up with an workable SQL approach to this problem, one simply does not exist!
Jul 16 '07 #15
NeoPa
32,579 Recognized Expert Moderator MVP
I completely understand, NeoPa. Interesting problem, the thorn in the side is the TOP 3 fastest times per runner and not overall, as well as implementing the solution in a Report Footer. I'm pretty sure I can devise a solution as described in the previous Post but I'm just laying back until someone comes up with a better solution or the OP wants to take this approach. To your credit, I figure that if you can't come up with an workable SQL approach to this problem, one simply does not exist!
You're right ADezii. I tried and failed :(
I sort of have a lingering suspicion that Rabbit may know of a way but my experience with subqueries is in the FROM clause, which can't work due to the TOP 3 predicate as you say. I could do a single one without using the subquery in the FROM clause but in the SELECT clause instead, but if it is possible to do this all in the select clause it is very complicated and I've done enough on this one. Over an hour on one thread is too much.
I'd be interested in a SQL solution so I'll continue to monitor. Even a code solution wouldn't be too straightforward as the recordset needs to be able to drive a report.
Anyway, enough for now. I have work in the morning.

PS. Thanks for the vote of confidence, but Rabbit's found answers where I've failed before, although I like to think I know my way around SQL pretty well now.
Jul 16 '07 #16
emajka21
38 New Member
I appreciate everyones help and I apologize for it taking me a couple of days to get back to you. On top of this I have 2 other classes and a full time job so the past two days I have been working on other things. Since this sounds so complicated and I do have it "working" in ASP/C# let me talk to the running clubs director and see which way she would prefer it, a stand alone access database or a website that everyone can get to (that being the good and the bad thing about it.) It is the security that has me stumped in the c#/asp program and has me doubting if that was the best way to go.

As for NeoPa's question: Can you confirm that the Race table will only have the nine races in it then (always)?

This is all the table will have. This will only be 8) 4 mile legs and 1) 10 mile leg.

Again, thank you all for your help. I will try to get together with her today or tomorrow and I will post her decision.
Jul 18 '07 #17
NeoPa
32,579 Recognized Expert Moderator MVP
Thanks for the update.
However, I'd proceeded along those lines already and petered out after an hour or two. If anything comes to me or I "see" a way through, then I'll post it, but please continue to breathe normally in the mean time ;)
I'm sorry to let you down. I hate it when that happens, but there it is - at least for now.
Jul 18 '07 #18
emajka21
38 New Member
No worries, the race director loved the website... I just have to figure out the best way to do security...
Jul 20 '07 #19

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

Similar topics

3
12110
by: Fran Zablocki | last post by:
I am trying to write an expression that converts one set of values to another. There are two fields, STAGE and ADMIT_TYPE, which are used as input criteria, and the final converted values are placed in the APPSTATUS field. The rules for the conversion are as follows: If STAGE = 600 then APPSTATUS = 03 If STAGE > 300 then APPSTATUS = 01 If STAGE > 300 and ADMIT_TYPE = AF or AFD or AP or APD, then APPSTATUS
1
3814
by: Grant Hammond | last post by:
I assume I'm not alone in my frustration that the expression builder that comes (in part) with Access XP that dosnt wrap text when you open it on an exisitng expression in a query or form. I's bad enough that Microsoft dropped the expression builder from the VB window (which I have restored using Michael Kaplan addin), but I cant understand how they could not have fixed this obviously and annoying BUG!@
1
2539
by: Laertes | last post by:
Hi, I want to use the expression builder in a query to define a field. I know how to do it for simple fields, like the one below : orderdate: IIf((IsNull() And =False) Or (<>"N/A" And =False),,) When though the expression is too complex, the builder is not very convenient to use. I tried to use a function instead... The error I
3
2042
by: X_HOBBES | last post by:
I'm fairly new to Access, let alone Expression Builder. However, it seems that I'm either doing something really wrong or Access is really stupid! I can't reference fields that show up on my report! For example, if I have a field named MyField on my report, the Control Source has the value MyField, and it displays the values of MyField properly in the report. If I try to use an expression as simple as =, it fails! I get "# Error"...
2
7372
by: Mike Turco | last post by:
I like using the expression builder for a lot of different things but it isn't always available when I want to use it, for example in the code window, or in all of the control properties. I am usually stuck having to go into the database window, creating a new query, etc., and then right-clicking in a field and selecting build. Is there a shortcut key, a way to add a button to an Access toolbar, or something like that so I can use to...
1
1727
by: Don | last post by:
I'm trying to build a simple report. It will show debtors, budgeted amounts and how much was actually paid to those debtors. I've tried using the expression builder, though I've never used it before I somehow believe I know how, apparently not! I chose the location of where the data is stored and the expression builder put it into the expression builder window. When I run the report I get this #name?. I guess that means it doesn't...
2
3019
by: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text index on one column, and punctuation in the column was causing some problems down the line. This column is used only for full text indexing, and otherwise ignored. I decided to use the following regular expression to remove all punctuation (actually...
0
2481
by: AlexanderTodorovic | last post by:
Hello Everyone, I'm developing a client application in which the users need an expression builder as provided in MS Access 2003. I would like to use the expression builder in a C# application. Is is possible to call the expression builder e.g. via automation? If yes, how can i execute the rules and get the result?
3
10374
by: rrosynek | last post by:
I have a 2003 Access Database with several tables related in a one to many relationship with a parent I am looking to build a report which evaluates if different users of the table have all entered data properly. As an example - the parent table creates the customer account number, customer last name and customer ssn. A related table creates all other customer information including address, phone etc., another related table contains...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
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 we have to send another system

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.