I am looking for a way to return the type of bill rate with the highest reimbursement rate.
Of the three variables that I am searching against, I'd like to store the name of the variable returned to the table so that users can determine which billing type was used.
This code pulls the billing rates from the database.
CenterAllRate = DLookup("CenterBillRateAllVendors", "Centers", "CenterID = " & Chr(34) & CenterID & Chr(34))
CenterHospitalRate = DLookup("CenterBillRateHospitalOnly", "Centers", "CenterID = " & Chr(34) & CenterID & Chr(34))
VendorRate = DLookup("VendorReimbRate", "Vendors", "VendorID = " & Chr(34) & Me.Parent.VendorID & Chr(34))
ReimbursementRate = MaxOfList(CenterAllRate, CenterHospitalRate, VendorRate)
I am using this prebuilt function that I found online to find the highest reimbursement rate of the three options.
Function MaxOfList(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMax As Variant 'Largest value found so far.
varMax = Null 'Initialize to null
For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Or IsDate(varValues(i)) Then
If varMax >= varValues(i) Then
'do nothing
Else
varMax = varValues(i)
End If
End If
Next
MaxOfList = varMax
End Function
How can I return either the name of the variable with the highest value, or give them aliases to use when creating the record?