I have an unbound text box which I use to get a calculation, called DM_SampleWt. This text box's control source is:
=GetSize([cbo_matTypeID],Nz([matBatchweight],0),[Form].[Parent]![txtpan],[Form].[Parent]![cbo_panID].[column](2))
I have written a function that will get the required sample weight of a material selected from my form
[cbo_matTypeID]- represents a combo box that allows the user to select the material type (bound)
matBatchweight- represents the batchweight of each material (user input, bound)
[txtpan]-bound text box representing the number of pans that need to be made
cbo_panID.column(2)- bound combo box, represents the pansize needed for the job, the column 2 represents the formula used in the calculation needed.
Here is my function:
Public Function GetSize(matType As Integer, BatchWeight As Double, NoOfPans As Double, PanFormulaValue As Double) As Double
'returns the required sample weight, 'DM_ReqSampWt' calculation
Select Case matType
'Cement, Coarse, Fine
Case 1, 2, 3
GetSize = BatchWeight * NoOfPans * PanFormulaValue / 27
Case 4
'Pigment
GetSize = BatchWeight * NoOfPans * PanFormulaValue / 27 / 0.0022
Case Else
GetSize = 0
End Select
End Function
DM_SampleWeight is automatically calculated after all of the above are input. The problem I am having (the function works perfectly) is that for material cement (cbo_matTYpeID = 1), I need to sum the DM_SampleWeight and I can't because I can not get a TOTAL SUM for a calculated value. I tried to use the same function like this:
=GetSize(Sum([cbo_matTypeID]=1),Nz([matBatchweight],0),[Form].[Parent]![txtpan],[Form].[Parent]![cbo_panID].[column](2))
How can I approach this problem? Thank you
1 1520 @csolomon
You could try building the Summation Logic into the Function like so, but I have no idea if this will actually work: - Public Function GetSize(matType As Integer, BatchWeight As Double, NoOfPans As Double, _
-
PanFormulaValue As Double) As Double
-
'returns the required sample weight, 'DM_ReqSampWt' calculation
-
Select Case matType
-
'Cement, Coarse, Fine
-
Case 1 'Unique case?
-
Dim MyDB As DAO.Database
-
Dim rstCalc As DAO.Recordset
-
Dim dblRunningSum As Double
-
-
Set MyDB = CurrentDb()
-
'Could also use an SQL Statement as basis for Recordeset ([Type] = 1)
-
Set rstCalc = MyDB.openrecordset("tblCalculation", dbOpenForwardOnly)
-
-
With rstCalc
-
Do While Not rstCalc.EOF
-
If ![Type] = 1 Then
-
dblRunningSum = dblRunningSum + (![BatchWeight] * ![NumOfPans] _
-
* ![PanFormulaValue] / 27)
-
End If
-
.MoveNext
-
Loop
-
GetSize = dblRunningSum 'Set the Function = the Aggregate Total
-
End With
-
rstCalc.Close
-
Set rstCalc = Nothing
-
Case 2, 3
-
GetSize = BatchWeight * NoOfPans * PanFormulaValue / 27
-
Case 4
-
'Pigment
-
GetSize = BatchWeight * NoOfPans * PanFormulaValue / 27 / 0.0022
-
Case Else
-
GetSize = 0
-
End Select
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics
by: rodger |
last post by:
hi all,
I have a form with two text boxes, a go button and a formula in the code
to perform a calculation a value is entered in one text box, and press
buttonm
a result is computed which is...
|
by: gavo |
last post by:
Hi.
using A2K; i have a form containing a continous subform. The question is,
how can i call a calculation for one of the fields in the continous subform
from the main form.
At the moment i...
|
by: Michiel Alsters |
last post by:
Hello everybody,
I hope anybody can help me. I'll try to give a brief overview of my
problem. I have running a program that performs a heavy calculation.
To give the user feedback what the...
|
by: linq936 |
last post by:
I have some algorithm dealing with unsigned int calculation a lot, I am
trying to add some check for overflow. The initial thinking was very
easy, just do something like this,
int...
|
by: David |
last post by:
Hi,
I have the following calculation I am trying to work out ..... Not sure
how ?
Variable 1 = minstock
Variable 2 = oDict(oKey)
I need to test if my variable 'minstock' <= 40% of...
|
by: gjoneshtfc |
last post by:
Hello,
I have an asp page that is a table. In the table the end column is a
calculation of other values, for example:
...
|
by: beach.dk |
last post by:
Hi,
I'm trying to implement a simple hash algorith called rs_hash in
javascript,
but I cannot get a correct result.
In c the code looks like this:
|
by: The alMIGHTY N |
last post by:
Hi all,
Let's say I have a simple math formula:
sum (x * y / 1000) / (sum z / 1000)
I have to do this across 50 items, each with an x, y and z value, when
the page first loads AND when a...
|
by: mattmao |
last post by:
Okay, I was asked by a friend about the result of this limit:
http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg
Not n->zero but n-> + infinite
I really...
|
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
|
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...
|
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: 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: 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: 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...
|
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...
| |