I'm having a bit of trouble with the syntax on a function i'm working on. It basically needs to calculate the criteria value for a DLookup. I'm coming from a perl background, so the ins and outs of vba elude me. Here's the code I have
Private Function gprank()
If Me.gpranknum = 1 Then
gprank = "Leading By" & Me.gpTtl - DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 2")
ElseIf Me.gpranknum = 2 Then
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 1") - Me.gpTtl & "Moves you to #1"
ElseIf Me.gpranknum = 3 Then
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 1") - Me.gpTtl & "Moves you to #1"
Else
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = [mugp_rank] - 2") - Me.gpTtl & "Moves you up 3 places"
End If
End Function
The last Else statement is the one i'm having trouble with.
Any assistance would be greatly appreciated.
-sA
Private Function gprank()
If Me.gpranknum = 1 Then
gprank = "Leading By" & Me.gpTtl - DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 2")
ElseIf Me.gpranknum = 2 Then
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 1") - Me.gpTtl & "Moves you to #1"
ElseIf Me.gpranknum = 3 Then
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = 1") - Me.gpTtl & "Moves you to #1"
Else
gprank = DLookup("[MU_GP]", "ranking_query", "[mugp_rank] = [mugp_rank] - 2") - Me.gpTtl & "Moves you up 3 places"
End If
End Function
The last Else statement is the one i'm having trouble with.
Any assistance would be greatly appreciated.
-sA
Last edited: