473,412 Members | 5,385 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,412 software developers and data experts.

Report question

I have a table with many fields ( 10 fields out of which 6 are for specific product issues). Each of those 6 has a number enter in it via a form.I've created a report and dont need to display these 6 fields. Instead i would like to display the maximum number entered in the fields in a group of records ( as i would sum records based on the persons name and date). I need to display only

eg..

Name vial , stopper , seals , codes , other
Joe 2 5 7 3 5

I would like to display "Seals" in the report as it is the highest number when all of Joe's records are summed.

How would i do that? Please Help ..
Dec 15 '06 #1
6 1251
MMcCarthy
14,534 Expert Mod 8TB
I have a table with many fields ( 10 fields out of which 6 are for specific product issues). Each of those 6 has a number enter in it via a form.I've created a report and dont need to display these 6 fields. Instead i would like to display the maximum number entered in the fields in a group of records ( as i would sum records based on the persons name and date). I need to display only

eg..

Name vial , stopper , seals , codes , other
Joe 2 5 7 3 5

I would like to display "Seals" in the report as it is the highest number when all of Joe's records are summed.

How would i do that? Please Help ..
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT Name, Max([vial]) As MaxVial, 
  2. Max([stopper]) As MaxStopper, Max([seals]) As MaxSeals,
  3. Max([codes]) As MaxCodes, Max([other]) As MaxOther
  4. FROM TableName
  5. GROUP BY Name;
  6.  
Mary
Dec 15 '06 #2
NeoPa
32,556 Expert Mod 16PB
I would like to display "Seals" in the report as it is the highest number when all of Joe's records are summed.
I tried doing this with multiple IIf() function calls and, though it is possible, it gets very complex very quickly, as more fields are added to the equation.
Instead I wrote a quick function in VBA (needs to be put in a general module or, if only required in the one report, it can be in the code for that report.
Expand|Select|Wrap|Line Numbers
  1. 'MaxVal Returns the string associated with the maximum value passed
  2. 'Parameters are passed in pairs,
  3. 'the first being the value and the second the associated string.
  4. Public Function MaxVal(ByVal lngVal As Long, _
  5.                        ByVal strAssoc As String, _
  6.                        ParamArray avarArgs() As Variant) As String
  7.     Dim intIdx As Integer
  8.  
  9.     intIdx = LBound(avarArgs)
  10.     If (UBound(avarArgs) - intIdx) Mod 2 <> 0 Then Stop
  11.     MaxVal = strAssoc
  12.     For intIdx = intIdx To UBound(avarArgs) Step 2
  13.         If avarArgs(intIdx) > lngVal Then
  14.             lngVal = avarArgs(intIdx)
  15.             MaxVal = avarArgs(intIdx + 1)
  16.         End If
  17.     Next intIdx
  18. End Function
The SQL to use it is :
[code]SELECT Name, MaxVal([vial],'Vial',
[stopper],'Stopper',
[seals],'Seals',
Expand|Select|Wrap|Line Numbers
  1. ,'Code',
  2.                     [other],'Other')
  3. FROM TableName
Dec 15 '06 #3
NeoPa
32,556 Expert Mod 16PB
Just noticed it is ALSO grouped by name.
Will post fixed version shortly.
Dec 15 '06 #4
NeoPa
32,556 Expert Mod 16PB
Simply change the SQL to :
[code]SELECT [Name], MaxVal(Max([vial]),'Vial',
Max([stopper]),'Stopper',
Max([seals]),'Seals',
Max(
Expand|Select|Wrap|Line Numbers
  1. ),'Code',
  2.                       Max([other]),'Other')
  3. FROM TableName
  4. GROUP BY [name]
If the word "Vial" is not actually required but the value instead, that is easier but I'm going from your question. If I'm wrong then I can change it quite quickly.
Dec 15 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Nice piece of code Adrian. I think I'll rob it.

Mary
Dec 16 '06 #6
NeoPa
32,556 Expert Mod 16PB
I like my code to be plagiarised (else why would I be here).
Dec 16 '06 #7

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

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
0
by: Danny J. Lesandrini | last post by:
First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got all the merge modules added to the project and it's working fine. The question is about...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
2
by: Tom | last post by:
This is related to an earlier post entitled "Text in Query/Numbers in Report" Brief recap - report has a query as a record source. The query shows the correct data, the report translating the...
0
by: Danny J. Lesandrini | last post by:
Didn't get any takers on this post this morning at dotnet.General, so I'm reposting here. First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got...
0
by: Kaur | last post by:
Hi, I am trying to create a crosstab type of report without using crosstab query. The report captures several survey questions and for each survey questions there are multiple choices that...
1
by: Stinky Pete | last post by:
Evening, I have a form that uses 5 pages (it's an electronic copy of the paper version) we are going to use for manufacturing non conformances and product deviations. In case your wondering,...
9
by: itmags | last post by:
I need to create a couple of reports, invoices, credit reports, etc... My question is: How/what is the best way to go about this using VB2005 / SQL Server 2000 Crystal Reports? MS Reporting?...
4
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the...
35
by: JessicaZ | last post by:
Hi everyone! I'm new here and have a question regarding Leban's report to pdf tool. I am working on a database where we are using this code to send a report out to pdf(duh) BUT what I need to do is...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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,...
0
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
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
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,...
0
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...

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.