D
DJJ
Can anybody tell me why this code does not work as a Public Function when
using declared variables but will work when explicitly referencing the
actual controls on the form (I would rather use the variables as this
function is called in several sub procedures)?
Private Sub txtLength_AfterUpdate()
str1 = Nz(Me.txtMetalType.Value, "")
dbl2 = Nz(Me.txtPlatWeight, 0)
dbl3 = Nz(Me.txtGoldWeight, 0)
dbl4 = Nz(Me.txtOtherWeight, 0)
dbl5 = Nz(Me.txtLength, 0)
dbl6 = Nz(Me.txtCastWeight, 0)
Call MetalWeight(str1, dbl2, dbl3, dbl4, dbl5, dbl6)
End Sub
Public Function MetalWeight(strMetal As String) ',dblPlatWt As Double, _
'dblGoldWt As Double, dblOtherWt As Double, dblLength As Double, dblCastWt
As Double)
Select Case strMetal
Case "PL"
dblPlatWt = FormatNumber(dblLength * dblCastWt, 2)
Case "B8", "G4", "G8", "R4", "R8", "W4", "W8", "W8L", _
"Y1", "Y2", "Y20", "Y22", "Y24", "Y4", "Y8", "Y9"
dblGoldWt = FormatNumber(dblLength * dblCastWt, 2)
Case "SBD", "SBD8", "SBL", "SBS", "SKB", "SY8", "Y4S", "Y8S"
dblOtherWt = FormatNumber(dblLength * dblCastWt, 2)
End Select
End Function
Thx
DJ
using declared variables but will work when explicitly referencing the
actual controls on the form (I would rather use the variables as this
function is called in several sub procedures)?
Private Sub txtLength_AfterUpdate()
str1 = Nz(Me.txtMetalType.Value, "")
dbl2 = Nz(Me.txtPlatWeight, 0)
dbl3 = Nz(Me.txtGoldWeight, 0)
dbl4 = Nz(Me.txtOtherWeight, 0)
dbl5 = Nz(Me.txtLength, 0)
dbl6 = Nz(Me.txtCastWeight, 0)
Call MetalWeight(str1, dbl2, dbl3, dbl4, dbl5, dbl6)
End Sub
Public Function MetalWeight(strMetal As String) ',dblPlatWt As Double, _
'dblGoldWt As Double, dblOtherWt As Double, dblLength As Double, dblCastWt
As Double)
Select Case strMetal
Case "PL"
dblPlatWt = FormatNumber(dblLength * dblCastWt, 2)
Case "B8", "G4", "G8", "R4", "R8", "W4", "W8", "W8L", _
"Y1", "Y2", "Y20", "Y22", "Y24", "Y4", "Y8", "Y9"
dblGoldWt = FormatNumber(dblLength * dblCastWt, 2)
Case "SBD", "SBD8", "SBL", "SBS", "SKB", "SY8", "Y4S", "Y8S"
dblOtherWt = FormatNumber(dblLength * dblCastWt, 2)
End Select
End Function
Thx
DJ