syntax help

btothap

jr. member, sr. lurker
Local time
Today, 04:41
Joined
May 9, 2003
Messages
20
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
 
Last edited:
ok, figgered it out

what with the single quotes and the double quotes and the whatnot.
I did find a somewhat useful reference here for folks coming in from different languages

http://pixelloom.com/resources/table.htm

pretty basic, but maybe helpful.

heres how it worked
Private Function gprank()

Dim rankadj
rankadj = Me.mugp_rank - 3

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] = " & rankadj & "") - Me.gpTtl & "Moves you up 3 places"
End If

End Function

-sA
 

Users who are viewing this thread

Back
Top Bottom