I was wondering if someone would be able to point me in the right direction here. I've got some VBA code as seen below
Code:
Public Function PPnts(PUs) As Single
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("PFT")
If rst![gender] = "M" And rst![Age] > 16 <= 29 Then
PPnts = DLookup("POINTS", "29MPUSHUPS", "PUSHUPS='" & PUs & "'")
ElseIf rst![gender] = "M" And rst![Age] >= 30 <= 39 Then
PPnts = DLookup("POINTS", "30-39M PUSHUPS", "PUSHUPS='" & PUs & "'")
ElseIf rst![gender] = "M" And rst![Age] >= 40 <= 49 Then
PPnts = DLookup("POINTS", "40-49M PUSHUPS", "PUSHUPS='" & PUs & "'")
ElseIf rst![gender] = "M" And rst![Age] >= 50 <= 59 Then
PPnts = DLookup("POINTS", "50-59M PUSHUPS", "PUSHUPS='" & PUs & "'")
ElseIf rst![gender] = "M" And rst![Age] >= 60 Then
PPnts = DLookup("POINTS", "60M PUSHUPS", "PUSHUPS='" & PUs & "'")
End If
End Function
Now it works to an extent except that it is only returning results from the "29MPUSHUPS" table as opposed to verifying the age and selecting the appropriate table before returning the corresponding points value. If anyone can help that would be awesome as I've been trying to figure it out for hours now.
Thanks in advance.