Hello again! I am writing a function that will search one of two listboxes depending on a different variable.

This is how I'm attempting to do it:


Code:
Public Function GetPoints(TheirName As String)
Dim CurrentScore As Integer
Dim theirpos As Integer
Dim TheList As ListBox
Dim team as integer

team = 1

'IGNORE EVERYTHING FROM HERE
If dummy.TeamGame.value = 1 Then
    If theirpos = -1 Then
        theirpos = FindPlayer(TheirName, frmPlayers.playerlist2)
        team = 2
    End If
End If
'TO HERE!

'HERE IS MY PROBLEM:
If team = 1 Then TheList = frmPlayers.playerlist1
If team = 2 Then TheList = frmPlayers.playerlist2


theirpos = FindPlayer(TheirName, TheList)
thelistname = TheList.List(theirpos)
seppos = InStr(1, thelistname, "|", vbTextCompare)
CurrentScore = Val(Mid$(TheirName, seppos + 2))
GetPoints = CurrentScore

End Function
At the part where I have
Code:
If team = 1 Then TheList = frmPlayers.playerlist1
If team = 2 Then TheList = frmPlayers.playerlist2
I get the following error:
Run-Time error 91:
Object variable or With block variable not set.


Any suggestions?