Math calculation in query

A

Ac

Hi,

I try to convert the math calculation from the Excel to the Access in a
query because the original is not user friendly.

The partial of the code and the Excel formula are as below. When I ran the
program, I got error message: Type Mismatched on GasRateInMMCF = (((CalF32) ^
2 - (BHP) ^ 2) / (((CalF32) ^ 2) - (BHP) ^ 2)) * InpE19 line. How can I solve
this problem? And also I would like to know how to write a loop for generate
the results as in the Excel sheet and display the results in the query
window. Thanks!


Dim BHP, CalF32, InpE19, GasRateInMMCF As Double

BHP = "SELECT (qGas Informatiom).[Flowing bhp from gas] FROM (qGas
Informatiom)" ‘BHP is $V$4
CalF32 = "SELECT (qReservoir Information).[Reservoir pressure] FROM
(qReservoir Information)"
InpE19 = "SELECT InputData.[Gas Flow Rate] FROM InputData"

GasRateInMMCF = (((CalF32) ^ 2 - (BHP) ^ 2) / (((CalF32) ^ 2) - (BHP) ^
2)) * InpE19


Here is the example of Excel field for GasRateInMMCF calculation:

=((CalculatedResults!F32^2-(V4)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V5)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V6)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V7)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V8)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V9)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V10)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V11)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V12)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V13)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V14)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V15)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V16)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V17)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V18)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V19)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V20)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V21)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V22)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V23)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V24)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V25)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V26)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
=((CalculatedResults!F32^2-(V27)^2)/((CalculatedResults!F32^2)-($V$4)^2))*InputData!E19
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top