Good Morning everyone:
I am creating a program that as the form loads displays a list of approximately 56,000 names. From this list the user will click on a name. As this is done all the informaiton from several tables will appear on the form. The form consists of a Tab Set of 8 tabs. There are a variety of textboxes, combo boxes, list boxes, etc.
What the problem is: As I click on the name and try to grab information for each of the fields on the form, it gives me this error: "VB6.exe has generated errors and will be closed by Windows. You will need to restart the program."
The error only occurs when I click on a name from the list.
I have never seen this error before, can anyone explain to me what exactly this means, and why?
Here is the code that is associated with the name click event.
Private Sub lstPlayers_Click()
Rem as player is selected, display all info from appropriate record in controls on the form
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Common.mdb"
Set rs = New Recordset
Dim strSQL As Variant
Dim spacepos As Integer
spacepos = InStr(lstPlayers.Text, " "
Set rs = db.Execute(("select * from Players where " & "FirstName = " & "'" & Left(lstPlayers, spacepos - 1) & "'" & " and " & "LastName = " & "'" & Right(lstPlayers.Text, Len(lstPlayers.Text) - spacepos) & "'", db, adCmdText)
txtLstNme.Text = rs.Fields("LastName" & vbNullString
txtFrstNme.Text = rs.Fields("FirstName" & vbNullString
txtCommon.Text = rs.Fields("CommonName" & vbNullString
txtMiddle.Text = rs.Fields("MiddleName" & vbNullString
txtPhonetic.Text = rs.Fields("Phonetic" & vbNullString
txtHomeTown.Text = rs.Fields("HomeTown" & vbNullString
txtBirthPlace.Text = rs.Fields("BirthPlace" & vbNullString
txtColNotes.Text = rs.Fields("Notes" & vbNullString
txtJersey.Text = rs.Fields("Jersey" & vbNullString
txtHeight.Text = rs.Fields("Height" & vbNullString
txtWeight.Text = rs.Fields("Weight" & vbNullString
cboShot.Text = rs.Fields("Shot" & vbNullString
If rs.Fields("InActive".Value = 0 Then
Let chkActive.Value = False
End If
If rs.Fields("IsPro".Value = 0 Then
Let optAmt.Value = True
Else
Let optProf.Value = True
End If
If rs.Fields("European".Value = 0 Then
Let optAmer.Value = True
Else
Let optEuropean.Value = True
End If
Set rs = db.Execute("SELECT Leagues.[Index], Leagues.[ShortName] FROM Leagues WHERE Leagues.[Index] IN SELECT Teams.[Index], Teams.[LongName], Players.[CurTeam] " & " FROM Teams, Players WHERE Players.[CurTeam] = Teams.Index"
cboLeague.Text = rs.Fields("ShortName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Positions.[Index], Positions.[Long], Players.[Position] " & " FROM Positions, Players WHERE Players.[Position] = Positions.Index", db, adCmdText)
cboPosition.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT DraftCodes.[Index], DraftCodes.[Description], Players.[DraftStatus] " & " FROM DraftCodes, Players WHERE Players.[DraftStatus] = DraftCodes.Index", db, adCmdText)
cboStatus.Text = rs.Fields("Description" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Countries.[Index], Countries.[Long], Players.[SCountry]" & " FROM Countries, Players WHERE Players.[SCountry]= Countries.Index", db, adCmdText)
cboNation.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Contacts.[Index], Contacts.[LastName], Contacts.[FirstName], Players.[Agent] " & " FROM Contacts, Players WHERE Players.[Agent] = Contacts.Index", db, adCmdText)
cboAgent.Text = rs.Fields("FirstName" & " , " & rs.Fields("LastName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[CurTeam] " & " FROM Teams, Players WHERE Players.[CurTeam] = Teams.Index", db, adCmdText)
cboCurTeam.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT NHLResTypes.[Index], NHLResTypes.[Long], Players.[NHLResType] " & " FROM NHLResTypes, Players WHERE Players.[NHLResType] = NHLResTypes.Index", db, adCmdText)
cboType.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[NHLResTeam] " & " FROM Teams, Players WHERE Players.[NHLResTeam] = Teams.Index", db, adCmdText)
cboTeam.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[ColCommit] " & " FROM Teams, Players WHERE Players.[ColCommit] = Teams.Index", db, adCmdText)
cboColCom.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT CollegeYears.[Index], CollegeYears.[Long], Players.[ColYear] " & " FROM CollegeYears, Players WHERE Players.[ColYear] = CollegeYears.Index", db, adCmdText)
cboYear.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT DraftDetails.[Round],DraftDetails.[Team], DraftDetails.[Overall], DraftDetails[Player], Players.[Index],Teams.[Index],Teams[LongName]" & " FROM DraftDetails, Players, Teams WHERE DraftDetails.[Player] = Players.Index", db, adCmdText)
lstDraft.AddItem rs.Fields("LongName"
txtRound.Text = rs.Fields("Round" & vbNullString
txtOverall.Text = rs.Fields("Overall" & vbNullString
rs.Close
Set rs = Nothing
'rs.Close
'Set rs = Nothing
End Sub
Thanks for any help!!
MichHart
" Never regret yesterday because it cannot be changed;
Instead make sure today does not become a regret of tomorrow."
I am creating a program that as the form loads displays a list of approximately 56,000 names. From this list the user will click on a name. As this is done all the informaiton from several tables will appear on the form. The form consists of a Tab Set of 8 tabs. There are a variety of textboxes, combo boxes, list boxes, etc.
What the problem is: As I click on the name and try to grab information for each of the fields on the form, it gives me this error: "VB6.exe has generated errors and will be closed by Windows. You will need to restart the program."
The error only occurs when I click on a name from the list.
I have never seen this error before, can anyone explain to me what exactly this means, and why?
Here is the code that is associated with the name click event.
Private Sub lstPlayers_Click()
Rem as player is selected, display all info from appropriate record in controls on the form
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Common.mdb"
Set rs = New Recordset
Dim strSQL As Variant
Dim spacepos As Integer
spacepos = InStr(lstPlayers.Text, " "
Set rs = db.Execute(("select * from Players where " & "FirstName = " & "'" & Left(lstPlayers, spacepos - 1) & "'" & " and " & "LastName = " & "'" & Right(lstPlayers.Text, Len(lstPlayers.Text) - spacepos) & "'", db, adCmdText)
txtLstNme.Text = rs.Fields("LastName" & vbNullString
txtFrstNme.Text = rs.Fields("FirstName" & vbNullString
txtCommon.Text = rs.Fields("CommonName" & vbNullString
txtMiddle.Text = rs.Fields("MiddleName" & vbNullString
txtPhonetic.Text = rs.Fields("Phonetic" & vbNullString
txtHomeTown.Text = rs.Fields("HomeTown" & vbNullString
txtBirthPlace.Text = rs.Fields("BirthPlace" & vbNullString
txtColNotes.Text = rs.Fields("Notes" & vbNullString
txtJersey.Text = rs.Fields("Jersey" & vbNullString
txtHeight.Text = rs.Fields("Height" & vbNullString
txtWeight.Text = rs.Fields("Weight" & vbNullString
cboShot.Text = rs.Fields("Shot" & vbNullString
If rs.Fields("InActive".Value = 0 Then
Let chkActive.Value = False
End If
If rs.Fields("IsPro".Value = 0 Then
Let optAmt.Value = True
Else
Let optProf.Value = True
End If
If rs.Fields("European".Value = 0 Then
Let optAmer.Value = True
Else
Let optEuropean.Value = True
End If
Set rs = db.Execute("SELECT Leagues.[Index], Leagues.[ShortName] FROM Leagues WHERE Leagues.[Index] IN SELECT Teams.[Index], Teams.[LongName], Players.[CurTeam] " & " FROM Teams, Players WHERE Players.[CurTeam] = Teams.Index"
cboLeague.Text = rs.Fields("ShortName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Positions.[Index], Positions.[Long], Players.[Position] " & " FROM Positions, Players WHERE Players.[Position] = Positions.Index", db, adCmdText)
cboPosition.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT DraftCodes.[Index], DraftCodes.[Description], Players.[DraftStatus] " & " FROM DraftCodes, Players WHERE Players.[DraftStatus] = DraftCodes.Index", db, adCmdText)
cboStatus.Text = rs.Fields("Description" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Countries.[Index], Countries.[Long], Players.[SCountry]" & " FROM Countries, Players WHERE Players.[SCountry]= Countries.Index", db, adCmdText)
cboNation.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Contacts.[Index], Contacts.[LastName], Contacts.[FirstName], Players.[Agent] " & " FROM Contacts, Players WHERE Players.[Agent] = Contacts.Index", db, adCmdText)
cboAgent.Text = rs.Fields("FirstName" & " , " & rs.Fields("LastName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[CurTeam] " & " FROM Teams, Players WHERE Players.[CurTeam] = Teams.Index", db, adCmdText)
cboCurTeam.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT NHLResTypes.[Index], NHLResTypes.[Long], Players.[NHLResType] " & " FROM NHLResTypes, Players WHERE Players.[NHLResType] = NHLResTypes.Index", db, adCmdText)
cboType.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[NHLResTeam] " & " FROM Teams, Players WHERE Players.[NHLResTeam] = Teams.Index", db, adCmdText)
cboTeam.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT Teams.[Index], Teams.[LongName], Players.[ColCommit] " & " FROM Teams, Players WHERE Players.[ColCommit] = Teams.Index", db, adCmdText)
cboColCom.Text = rs.Fields("LongName" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT CollegeYears.[Index], CollegeYears.[Long], Players.[ColYear] " & " FROM CollegeYears, Players WHERE Players.[ColYear] = CollegeYears.Index", db, adCmdText)
cboYear.Text = rs.Fields("Long" & vbNullString
rs.Close
Set rs = Nothing
Set rs = db.Execute(("SELECT DraftDetails.[Round],DraftDetails.[Team], DraftDetails.[Overall], DraftDetails[Player], Players.[Index],Teams.[Index],Teams[LongName]" & " FROM DraftDetails, Players, Teams WHERE DraftDetails.[Player] = Players.Index", db, adCmdText)
lstDraft.AddItem rs.Fields("LongName"
txtRound.Text = rs.Fields("Round" & vbNullString
txtOverall.Text = rs.Fields("Overall" & vbNullString
rs.Close
Set rs = Nothing
'rs.Close
'Set rs = Nothing
End Sub
Thanks for any help!!
MichHart
" Never regret yesterday because it cannot be changed;
Instead make sure today does not become a regret of tomorrow."