473,387 Members | 1,535 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,387 software developers and data experts.

Get The Minimum Value From A Textbox

37 32bit
I have a report where I am trying to get the minimum value from a calculated textbox named "TMetalic" which calculates the total of each component.

The main group named 'Caliber" shows different Calibers
The next group named "Component" lists three different components with detail items and quantities. In the Component Footer is where "TMetalic" sets, totaling the quantity of each component.

I want to place a textbox named "CanBuild" next to the group named "Caliber" to show a minimum value I can build based on the lowest total of all three components.

Example:
Caliber = 9mm
Components and Totals:
Brass = 2,000
Primer = 1,000
Projectile = 2,000
The minimum value is 1,000 Primers
Next to Caliber: 9mm is a textbox "CanBuild" showing "1,000" as the number of cartridges I can reload.

Any ideas, I have reading and trying sense yesterday.
Nov 15 '22 #1

✓ answered by NeoPa

Hi Curious.

I think you may already know that individual Component totals are no longer available once the next Component is processed and thus, by the time the Caliber total is reached only the very last of them is still available. Comparing them at this stage just can't work.

What you could do however, is to write some code in various Events to get around it.

The Calibre Header would set a stored variable to -1 to indicate that it's, as yet, unset.

The Format or Print Event of the Component Footer replaces this when the current value is less than the existing one or the existing one is unset (-1).

The Calibre Footer would set a special (unbound) TextBox to the value of this variable so that you get the value you want printed.

5 6467
NeoPa
32,556 Expert Mod 16PB
Hi Curious.

I think you may already know that individual Component totals are no longer available once the next Component is processed and thus, by the time the Caliber total is reached only the very last of them is still available. Comparing them at this stage just can't work.

What you could do however, is to write some code in various Events to get around it.

The Calibre Header would set a stored variable to -1 to indicate that it's, as yet, unset.

The Format or Print Event of the Component Footer replaces this when the current value is less than the existing one or the existing one is unset (-1).

The Calibre Footer would set a special (unbound) TextBox to the value of this variable so that you get the value you want printed.
Nov 15 '22 #2
Curious27
37 32bit
Hi NeoPa

You are right, I did lose sight of the component totals not being available as individual totals. I'll write some code to separate the component totals so a minimum total can be placed in textbox "CanBuild".

Thanks again and have a Happy Thanksgiving.
Nov 15 '22 #3
Curious27
37 32bit
NeoPa

Here is an update as to how you and I have solved my problem. As stated above I wanted to place a textbox "CanBuild" next to the Group Header "Caliber" to show how many cartridges can be loaded, based on the totals of each component and selecting the lowest amount available.

What I did was create three textboxes in the Component Footer and naming them, txtTBrass, txtTPrimer, txtTProjectile. I made them not visible for the report aesthetics.
Then in the Control Source for each one, I put it's own expression;

Expand|Select|Wrap|Line Numbers
  1. =Sum(IIf([Component]='Brass',[mAvailQty],0))
  2. =Sum(IIf([Component]='Primer',[mAvailQty],0))
  3. =Sum(IIf([Component]='Projectile',[mAvailQty],0))
  4.  
Doing this, pulled out each component, Brass, Primer and Projectile's totals. Then in the textbox "CanBuild" I placed it it's Control Source this expression;

Expand|Select|Wrap|Line Numbers
  1. =MinOf([txtTBrass],[txtTPrimer],[txtTProjectile])
Now in "CanBuild" I have the minimum amount of cartridges I can make, based on the component stock levels.

I would also like to thank you for the valuble lesson you taught me on the value of making a Public Function; we named as "MinOf". This was put together to solve a problem I had a couple months back where you told me it would be better to make a Public Function and have it available through out my project rather than writing an expression for the Control Source each time I needed to find a minimum value. Well, here I am calling on that public function and it works like a charm. Appreciated, is the fact that you took the time to teach me the How, Why and Where of this function.

For those interested in that function, I'll place it here.

Expand|Select|Wrap|Line Numbers
  1. Public Function MinOf(varA As Variant _
  2.                     , varB As Variant _
  3.                     , varC As Variant) As Variant
  4.     If IsNumeric(varA) _
  5.     And IsNumeric(varB) _
  6.         And IsNumeric(varC) Then
  7.         MinOf = varA
  8.         If MinOf > varB Then MinOf = varB
  9.         If MinOf > varC Then MinOf = varC
  10.  
  11.     End If
  12. End Function
Again, Thank you.
Nov 16 '22 #4
NeoPa
32,556 Expert Mod 16PB
Hi Curious.

How very pleasant to receive such a post. Very gracious of you :-)

I'm happy to see that, with a clearer understanding of the issue, you were able to find a solution, that was different from my suggestion, yet was a perfect solution for you.
Nov 17 '22 #5
Curious27
37 32bit
That's the beauty of programming, so many ways to achievement.

Have a good day.
Nov 17 '22 #6

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

Similar topics

4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
3
by: RobG | last post by:
I would like a query that will tell me the minimum non-zero value in a row. Say I have a table with a column called recordID that contains unique record IDs, and have a set of values named V1,...
5
by: Bas Wassink | last post by:
Hi there, I was wondering what the standard (C89) states what the minimum value of FOPEN_MAX should be? K&R just state that FOPEN_MAX is implementation-defined and when googling for an answer I...
3
by: VB Programmer | last post by:
In my ASPX page how do I get the .text value of a textbox that is in the ItemTemplate of a datalist (using HTML)? The textbox contains the quantity for a shopping cart item. The textbox is...
1
by: alan_conoco | last post by:
Hello all, I have a table looks like this in Access Product Sale Date A date A date A date B date B ...
3
by: saif9171 | last post by:
Hi: Here is my question... Below program needs arguments from command line. How to modify the parent program to provide at least five integers inside of the program, not from command line and keep...
7
by: mingke | last post by:
I tried to find max and min value from arrays. and my code so far looks like this: for (i=0; i<size2; i++){ for (j = 0; j < 4; j++){ by_max=by; if...
5
by: omar999 | last post by:
hi - im trying to return the minimum value from selected columns. however for some non obvious reason it only works when 3digit long numbers are entered in to the columns in question. the below...
1
by: peachdot | last post by:
hi, i used min() to find the minimum value of an array/list. it gives the min value of each row. But how do i know in which column does the min value is..? a=for j in range(4)] a= a= a= a=
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...

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.