If I was in Excel, I would simply use a vlookup set to true, but I couldn't find a way to accomplish this in access, short of the function below.
In short, attached is the table it's looking at.
Thanks for any insight,
Gary
In short, attached is the table it's looking at.
Code:
Public Function ConThreshold(x As Currency)
'set up the dims
Dim limit1 As Currency
Dim limit2 As Currency
Dim limit3 As Currency
Dim limit4 As Currency
Dim limit5 As Currency
Dim limit6 As Currency
Dim RowID As Integer
'Set the values
limit1 = DLookup("JobSize", "tblContributionValues", "ID = 1")
limit2 = DLookup("JobSize", "tblContributionValues", "ID = 2")
limit3 = DLookup("JobSize", "tblContributionValues", "ID = 3")
limit4 = DLookup("JobSize", "tblContributionValues", "ID = 4")
limit5 = DLookup("JobSize", "tblContributionValues", "ID = 5")
'Figure out the Contribution Threshold for the given job
If x >= limit1 And x < limit2 Then
RowID = 1
End If
If x >= limit2 And x < limit3 Then
RowID = 2
End If
If x >= limit3 And x < limit4 Then
RowID = 3
End If
If x >= limit4 And x < limit5 Then
RowID = 4
End If
If x >= limit5 Then
RowID = 5
End If
MsgBox DLookup("ContributionThreshold", "tblContributionValues", "ID = " & RowID), vbOKOnly
'set Global Variable for Threshold for further calculations
gvThreshold = DLookup("ContributionThreshold", "tblContributionValues", "ID = " & RowID)
End Function
Thanks for any insight,
Gary