Hello again! I am currently working on a code that discovers an items weight and uses a conversion method to convert that into a specific type. Now the big issue here is that in my code I have a Select Case for the weight (since there are three columns available for the weight) but it keeps defaulting to the Case Else even though there is clearly other Case matches above it. Here is my code:
Code:
Private Sub AnalysisUNITS_AfterUpdate()
Dim resultsBegin As Integer
Dim resultsFinish As Integer
Dim calculationGramLiter As Integer
Dim calculationWeightPerc As Integer
Dim finalSG As Integer
Dim InvNum As Integer
'Transferring Data from form onto VB code
[resultsBegin] = [AnalysisResults]
[InvNum] = 999
Select Case [SampleSG]
Case SampleSG.Value > 0
[finalSG] = SampleSG.Value
Case SampleSG_SP.Value > 0
[finalSG] = SampleSG_SP.Value
Case SampleSG_LAB.Value > 0
[finalSG] = SampleSG_LAB.Value
Case Else
MsgBox ("Please Enter a SG before continuing.")
[Results] = [InvNum]
End Select
Select Case [AnalysisUNITS]
Case [AnalysisUNITS] < 0
MsgBox ("Please Enter the Analysis Units of Measure.")
[Results] = [InvNum]
Case [AnalysisUNITS] = 4
[calculationWeightPerc] = [resultsBegin]
Case [AnalysisUNITS] = 1
[calculationGramLiter] = [resultsBegin]
[calculationWeightPerc] = [calculationGramLiter] / [finalSG] / 10
Case [AnalysisUNITS] = 2, 6, 8
[calculationGramLiter] = [resultsBegin] * 1000
[calculationWeightPerc] = [calculationGramLiter] / [finalSG] / 10
Case [AnalysisUNITS] = 7
[calculationGramLiter] = [resultsBegin] * 1000000
[calculationWeightPerc] = [calculationGramLiter] / [finalSG] / 10
Case [AnalysisUNITS] = 56, 68
[calculationGramLiter] = [resultsBegin] * 0.001
[calculationWeightPerc] = [calculationGramLiter] / [finalSG] / 10
Case Else
'Do Nothing
End Select
Select Case [calculationWeightPerc]
Case [calculationWeightPerc] < 0
[resultsFinish] = [InvNum]
Case [calculationWeightPerc] > 100
[resultsFinish] = [InvNum]
Case Else
[resultsFinish] = [calculationWeightPerc]
End Select
[Results] = [resultsFinish]
'MsgBox ("The Criteria is " & Criteria & " the Value is " & AnalysisUNITS.Value)
End Sub