Case statement issue

G

Guest

The value from the first statement is the value that is always returned even
if
[Vec_rlpte_Dys_Qty] = 31 to 60 or 61 to 90 I still get the value from the
first statement returned (0.5434). Does something need to be reset each
time? Do I need some changes in my coding? Please help THANK YOU JZ!!


Function ResultCalc(EPTG_ACUT_ETG_IND As Double, _
Vec_rlpte_Dys_Qty As Double) As Double

If (EPTG_ACUT_ETG_IND = 0) Then
Select Case Vec_rlpte_Dys_Qty

Case 0 To 30
ResultCalc = 0.5434
Case 31 To 60
ResultCalc = 0.6769
Case 61 To 90
ResultCalc = 0.7579
Case 91 To 120
ResultCalc = 0.8168
End Select
End If
End Function
 
J

Jason Lepack

I copied and pasted your function in and it worked fine for me.
The only problem I have is that your function doesn't know what to
return if EPTG_ACUT_ETG_IND is not zero or if Vec_rlpte_Dys_Qty is
less than zero (which I assume it can't be) or greater than 120
(probably possible).

I added in a couple lines.

This covers all other values of Vec_rlpte_Dys_Qty:
Case Else
ResultCalc = -1

This covers areas where EPTG_ACUT_ETG_IND is not zero
Else
ResultCalc = -2

Function ResultCalc(EPTG_ACUT_ETG_IND As Double, _
Vec_rlpte_Dys_Qty As Double) As Double

If (EPTG_ACUT_ETG_IND = 0) Then
Select Case Vec_rlpte_Dys_Qty
Case 0 To 30
ResultCalc = 0.5434
Case 31 To 60
ResultCalc = 0.6769
Case 61 To 90
ResultCalc = 0.7579
Case 91 To 120
ResultCalc = 0.8168
Case Else
ResultCalc = -1
End Select
Else
ResultCalc = -2
End If
End Function

Cheers,
Jason Lepack
 
J

John Spencer

How are you calling this function?

Are you passing in the field values in the query using something like:

Field: SomeResult: ResultCalc([EPTG_ACUT_ETG_IND],[ec_rlpte_Dys_Qty])

This assumes that you have actually named the fields the same as the
arguments in the function.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

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