I wanted to post the entire code to see if there maybe a better way of doing
this and hopefully I can do a better job of explaining this...so here goes.
This is the entire function code.
Public Function CID01_Calc()
On Error Resume Next
Dim CT01 As Integer
'DIM Cabcond01 = 0 CT = Variable
Dim D010A, D010B, D010C, D010D, D010E, D010X As Double
Dim A010A, A010B, A010C, A010D, A010E, A010X As Double
'DIM Cabcond01 = 1 CT = Variable
Dim D011A, D011B, D011C, D011D, D011E, D011X As Double
Dim A011A, A011B, A011C, A011D, A011E, A011X As Double
Dim CABcond01 As Integer
Forms!frmCTFill!Wire01.Value = DLookup(" [UNGR_SIZE]", "tbl600V",
"[Design] = FORM![txbxCID01]")
CT01 = DLookup(" [CTFC]", "tbl600V", "[Design] = FORM![txbxCID01]")
CABcond01 = DLookup(" [CabTypCond]", "tbl600V", "[Design] =
FORM![txbxCID01]")
'Determine Whether Cable Type is Single Conductors or MultiConductors (0
= Multi, 1 = Single)
If CABcond01 = 0 Then '(MultiConductor)
'Determine Cable Type for correct Calculations (0 = 600V Multi, 1 = 600V
Single, 2 = Control Multi, 3 = 5KV Single, 4= 15KV Single)
If CT01 = 0 Then '(600V Multi)
D010A = 0
A010A = Forms!frmCTFill!txbxQan01.Value * DLookup(" [Cable_A]",
"tbl600V", "[Design] = FORM![txbxCID01]")
ElseIf CT01 = 1 Then '(600V Single) 'Sum of the Diameters per NEC
392.9 (A)(1)
D010B = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A010B = 0
ElseIf CT01 = 2 Then '(Control Multi)
D010C = 0
A010C = Forms!frmCTFill!txbxQan01.Value * DLookup(" [Cable_A]",
"tbl600V", "[Design] = FORM![txbxCID01]")
ElseIf CT01 = 3 Then '(5KV Single) - Based on Maintained spacing
between cable diameters (NEC 392.13(A)(2))
D010D = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A010D = 0
ElseIf CT01 = 4 Then '(15KV Single) - Based on Maintained spacing
between cable diameters (NEC 392.13(A)(2))
D010E = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A010E = 0
Else
D010X = 1000
A010X = 1000
End If
Else 'CABCond01 = 1 (Single Conductor)
'Determine Cable Type for correct Calculations (0 = 600V Multi, 1 = 600V
Single, 2 = Control Multi, 3 = 5KV Single, 4= 15KV Single)
If CT01 = 0 Then '(600V Multi) - Not applicable
D011A = 1000
A011A = 1000
ElseIf CT01 = 1 Then '(600V Single - NEC 391.10(A)(4)) - Triplexed
Cables Only
If Forms!frmCTFill!Wire01.Value = "1/0" Or _
Forms!frmCTFill!Wire01.Value = "2/0" Or _
Forms!frmCTFill!Wire01.Value = "3/0" Or _
Forms!frmCTFill!Wire01.Value = "4/0" Then
D011B = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A011B = 0
Else '(600V Single - NEC 391.10(A)(3)) - Triplexed Cables Only
D011B = 0
A011B = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_A]", "tbl600V", "[Design] = FORM![txbxCID01]")
End If
ElseIf CT01 = 2 Then '(Control Multi) - Not applicable
D011C = 1000
A011C = 1000
ElseIf CT01 = 3 Then '(5KV Single) - NEC 392.13(B)(3)) - Triplexed
Cables Only
D011D = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A011D = 0
ElseIf CT01 = 4 Then '(15KV Single) - NEC 392.13(B)(3)) - Triplexed
Cables Only
D011E = Forms!frmCTFill!txbxQan01.Value * DLookup("
[Cable_DIA]", "tbl600V", "[Design] = FORM![txbxCID01]")
A011E = 0
Else
D011X = 1000
A011X = 1000
End If
End If
Forms!frmCTFill!TD01.Value = (D010A + D010B + D010C + D010D + D010E
+ D010X + D011A + D011B + D011C + D011D + D011E + D011X)
Forms!frmCTFill!TCA01.Value = (A010A + A010B + A010C + A010D + A010E
+ A010X + A011A + A011B + A011C + A011D + A011E + A011X)
Forms!frmCTFill!WPF01.Value = Forms!frmCTFill!txbxQan01.Value *
DLookup(" [Cable_WT]", "tbl600V", "[Design] = FORM![txbxCID01]")
Forms!frmCTFill!TotWt.Value = Forms!frmCTFill!WPF01.Value +
Forms!frmCTFill!WPF02.Value + Forms!frmCTFill!WPF03.Value + Join_
Forms!frmCTFill!WPF04.Value Forms!frmCTFill!WPF05.Value +
Forms!frmCTFill!WPF06.Value + Forms!frmCTFill!WPF07.Value + Join_
Forms!frmCTFill!WPF08.Value Forms!frmCTFill!WPF09.Value +
Forms!frmCTFill!WPF10.Value + Forms!frmCTFill!WPF11.Value + Join_
Forms!frmCTFill!WPF12.Value Forms!frmCTFill!WPF13.Value +
Forms!frmCTFill!WPF14.Value + Forms!frmCTFill!WPF15.Value + Join_
Forms!frmCTFill!WPF16.Value Forms!frmCTFill!WPF17.Value +
Forms!frmCTFill!WPF18.Value + Forms!frmCTFill!WPF19.Value + Join_
Forms!frmCTFill!WPF20.Value Forms!frmCTFill!WPF21.Value +
Forms!frmCTFill!WPF22.Value + Forms!frmCTFill!WPF23.Value + Join_
Forms!frmCTFill!WPF24.Value
End Function
The reason for all the different variable within the function is becasue
based upon the conditions of the cable type [CABcond01]. [Cabcond01] looks at
the cable table and returns either a 0 or 1 bepending up what the user
selected in the form. It then performs different calculations based on the
National Electrical Code requirements. In some cases it needs to get the
diameter in other cases the area and sometimes both based upon the Voltage
class of the cable. The [CT01] variable gets the Cable Tray Fill Condition
[CTFC], again based upon the Cable selected by user from the cable table.
This [CT01] variable basically determines whether or not the cable can be
placed into a particular cable tray. For instance: the National Electrical
Code will not let you put a 600 Volt cable with a 15KV cable....so the [CT01]
will limit the selection. The code executes everything fine; but I need to
return the values of all the variables D010A, A010A, etc to another function
for other calculations.
Would it just be easier to store this information in an invisible field on
the form and then retrieve the information in the other function????
Any suggestions....
--
Heiko K Stugg
Heiko K Stugg said:
If I am calculating a variable in one function and I want to use the results
of that variable in another function; how can I accomplish this?
Calculated variable function code
Public Function CID15_Calc()
Dim D150B As Double
D150B = Forms!frmCTFill!txbxQAN15.Value * DLookup(" [Cable_DIA]", "tbl600V",
"[Design] = FORM![txbxCID15]")
End Function
I need to use the resultant of the equation to D150B in another function.
The only difference is that I have 24 of these resultants that need to be
added together within the function,but if I knew how to get one to work the
others would be easy.