473,787 Members | 2,928 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 #1
18 4426
NeoPa
32,578 Recognized Expert Moderator MVP
I don't think there is.
If you only showed the top three (using the TOP predicate in the underlying SQL) then that would work for you but the report is an Access object rather than a Jet SQL object. I'm fairly sure it can't be done there. Sorry.
Jul 15 '07 #2
ADezii
8,834 Recognized Expert Expert
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!
I'm with NeoPa, in that I also don't think it can be done in the manner which you describe. It probably can be done by setting the Control Source of a Text Box in the Report's Group Footer to a Function which receives each Grouping Field as an Argument and performs the neccessary summations on the Top 3 items in each Group. I really would like to stress the word probably here. If you wanted to attempt this approach, I would need much more information.
Jul 15 '07 #3
emajka21
38 New Member
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!
Jul 15 '07 #4
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!
This is all I had time to experiment with, but hopefully it will point you in the right direction. The following Parameter Query will return the 3 fastest times, (Total Seconds), for a specific individual for any number of 4-mile races. In addition to the 3 fastest times, it also outputs the BibNum, RaceNum, FirstName, LastName, and Sex. This should, at least, be a good starting point. I'm really not sure if what you are requesting is even possible. Good luck and keep in touch.
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 3 tblRunner.BibNum, RaceNum, FirstName, LastName, Sex, ([Minutes]*60+[Seconds]) AS Total_Time_In_Secs
  2. FROM tblRunner INNER JOIN tblRace ON tblRunner.BibNum = tblRace.BibNum
  3. GROUP BY tblRunner.BibNum, tblRace.RaceNum, FirstName, LastName, Sex, ([Minutes]*60+[Seconds])
  4. HAVING LastName=[Enter Last Name]
  5. ORDER BY tblRunner.BibNum, ([Minutes]*60+[Seconds]);
Jul 15 '07 #5
NeoPa
32,578 Recognized Expert Moderator MVP
What, in the Race table, indicates a 10 mile race?
Jul 15 '07 #6
emajka21
38 New Member
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.

I appreciate all of your help in this! I have less than one month to get this working. Not only do the races start mid august, but I am using this as my graduate project. So me graduating is depending on this. It didn't sound so hard in the beginning but now that I have been working on this for over a month (i took a detour and started writing it in asp/c# which I sort of have working, but I think I made it too complicated.) Anyways I thought I would come full circle and try it in a simpler version again in just access. I'm driving myself crazy because i keep running into unforseen problems and have to change my plan.

Again thanks for your help!!!
Jul 15 '07 #7
puppydogbuddy
1,923 Recognized Expert Top Contributor
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.
Jul 15 '07 #8
ADezii
8,834 Recognized Expert Expert
I don't think there is.
If you only showed the top three (using the TOP predicate in the underlying SQL) then that would work for you but the report is an Access object rather than a Jet SQL object. I'm fairly sure it can't be done there. Sorry.
Hello NeoPa:
The more I look at this, the more I agree with you in that this can't be accomplished in a Report Footer via SQL. The only logical solution that I see is to:
  1. Create a Multi-Line Text Box in the Report Footer.
  2. Set the Control Source of this Text Box to a Public Function, say fCalculateMarat honTimes().
  3. Within this Function, the 3 fastest times for a 4 mile race for each unique individual are summed and the result of their 10 mile race is added on to the summation.
  4. The Function will then return a concatenated string listing of all individuals with their accumulated times, (3 fastest 4-mile + 10 mile), such as:
    Expand|Select|Wrap|Line Numbers
    1. George Washington 23 mins. 34 secs.
    2. Theodore Roosevelt 31 mins. 17 secs.
    3. John Davidson 27 mins. 53 secs.
    4. ..
  5. I am also referring the OP to this post, but I wanted to get your expert opinion first. I also think that this approach should be implemented after all other possibilities have been exhausted. This may be the only way out since the SQL route in combination with a Report footer seems futile.
  6. BTW, this may be a little more difficult than I realize, in which case there will be no implementation at all (LOL).
  7. Please get back to me on this.
Jul 16 '07 #9
ADezii
8,834 Recognized Expert Expert
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.

I appreciate all of your help in this! I have less than one month to get this working. Not only do the races start mid august, but I am using this as my graduate project. So me graduating is depending on this. It didn't sound so hard in the beginning but now that I have been working on this for over a month (i took a detour and started writing it in asp/c# which I sort of have working, but I think I made it too complicated.) Anyways I thought I would come full circle and try it in a simpler version again in just access. I'm driving myself crazy because i keep running into unforseen problems and have to change my plan.

Again thanks for your help!!!
Please refer to my Reply to NeoPa's earlier Post. One way or another we'll try to get this to work for you - we love these kinds of challenges!

Dezii's Reply to Forum Leader NeoPa

There seems to be a little trouble with the Hyperlink, so I'm also posting the entire text.
Hello NeoPa:
The more I look at this, the more I agree with you in that this can't be accomplished in a Report Footer via SQL. The only logical solution that I see is to:
  1. Create a Multi-Line Text Box in the Report Footer.
  2. Set the Control Source of this Text Box to a Public Function, say fCalculateMarat honTimes().
  3. Within this Function, the 3 fastest times for a 4 mile race for each unique individual are summed and the result of their 10 mile race is added on to the summation.
  4. The Function will then return a concatenated string listing of all individuals with their accumulated times, (3 fastest 4-mile + 10 mile), such as:
    Expand|Select|Wrap|Line Numbers
    1. George Washington 23 mins. 34 secs.
    2. Theodore Roosevelt 31 mins. 17 secs.
    3. John Davidson 27 mins. 53 secs.
    4. ..
  5. I am also referring the OP to this post, but I wanted to get your expert opinion first. I also think that this approach should be implemented after all other possibilities have been exhausted. This may be the only way out since the SQL route in combination with a Report footer seems futile.
  6. BTW, this may be a little more difficult than I realize, in which case there will be no implementation at all (LOL).
  7. Please get back to me on this.
Jul 16 '07 #10

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

Similar topics

3
12109
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
3811
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
2537
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
1726
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
3017
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
10371
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
9497
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
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
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
10110
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
8993
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...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.