Hello all!
I need to compare 9 variables from a record and find out which one has the lowest value. Based on that, I can then assign a team to the overall record. I may need to weigh questions in case of a tie in score. I can write If/Then/Else statements to do this, but it seems rather cumbersome to write and definitely difficult to maintain later. I was thinking along the lines of calling a function from a query (getteam) and passing the 9 question values to it for calculation.
Function GetTeam(Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9) As String
Dim Team
<comparison example>
Q1 < other Qs Then
Team = "TeamFoo"
or
Q2 < other Qs Then
Team = "TeamBlah"
etc.,etc,
GetTeam = Team
End Function
I'm just not sure what the best way to run the comparison would be. A simple description would be to get the lowest question score and assign a team.
e.g. Q2 has lowest score so TeamBlah is what is returned to the query as the result for the record.
I appreciate any help - I've totally gone brain-numb on this one. If the If/Then/Else should be used then that's fine too, I just was looking for a 'clean' way to do it.
Thanks,
Kenneth Frazier, MCSE, CCA
Network Engineer
I need to compare 9 variables from a record and find out which one has the lowest value. Based on that, I can then assign a team to the overall record. I may need to weigh questions in case of a tie in score. I can write If/Then/Else statements to do this, but it seems rather cumbersome to write and definitely difficult to maintain later. I was thinking along the lines of calling a function from a query (getteam) and passing the 9 question values to it for calculation.
Function GetTeam(Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9) As String
Dim Team
<comparison example>
Q1 < other Qs Then
Team = "TeamFoo"
or
Q2 < other Qs Then
Team = "TeamBlah"
etc.,etc,
GetTeam = Team
End Function
I'm just not sure what the best way to run the comparison would be. A simple description would be to get the lowest question score and assign a team.
e.g. Q2 has lowest score so TeamBlah is what is returned to the query as the result for the record.
I appreciate any help - I've totally gone brain-numb on this one. If the If/Then/Else should be used then that's fine too, I just was looking for a 'clean' way to do it.
Thanks,
Kenneth Frazier, MCSE, CCA
Network Engineer