Please help me.
I have written this code in an attempt to count how many times a distinct name appears in a recordset set. I am a novice but Im sure i have declared all variables.
Set db = New Connection
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\vb98\Disciplin Manager 2\reporter.mdb"
Set adoRecordset2 = New Recordset
adoRecordset2.Open "select distinct Name from reportertb1", db, adOpenStatic, adLockOptimistic
DistinctRecCount = adoRecordset2.RecordCount
Call NameFind
Private Sub NameFind()
blnisopen = False
Dim i As Integer
adoRecordset2.Close
adoRecordset2.Open "select * From reportertb1", db, adOpenStatic, adLockOptimistic
adoRecordset2.MoveFirst
Set adoRecordset3 = New Recordset
For i = 1 To DistinctRecCount
Do While strName = adoRecordset2!Name
adoRecordset2.MoveNext
Loop
strName = "'" & adoRecordset2!Name & "'"
If blnisopen = True Then
adoRecordset3.Requery
Else
adoRecordset3.Open "select * From reportertb1 where Name = " & strName, db, adOpenStatic, adLockOptimistic
blnisopen = True
End If
RecNo = adoRecordset3.RecordCount
Set DataGrid1.DataSource = adoRecordset3
chtSample.DataGrid.SetData 1, i, RecNo, True
chtSample.Title = frmChoiceChart.strChart
Next i
I get an error at the setting the points on the chart at the moment but im not sure if the rest of the code will work at all. Any guidance would be appreciated. Thank you
I have written this code in an attempt to count how many times a distinct name appears in a recordset set. I am a novice but Im sure i have declared all variables.
Set db = New Connection
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\vb98\Disciplin Manager 2\reporter.mdb"
Set adoRecordset2 = New Recordset
adoRecordset2.Open "select distinct Name from reportertb1", db, adOpenStatic, adLockOptimistic
DistinctRecCount = adoRecordset2.RecordCount
Call NameFind
Private Sub NameFind()
blnisopen = False
Dim i As Integer
adoRecordset2.Close
adoRecordset2.Open "select * From reportertb1", db, adOpenStatic, adLockOptimistic
adoRecordset2.MoveFirst
Set adoRecordset3 = New Recordset
For i = 1 To DistinctRecCount
Do While strName = adoRecordset2!Name
adoRecordset2.MoveNext
Loop
strName = "'" & adoRecordset2!Name & "'"
If blnisopen = True Then
adoRecordset3.Requery
Else
adoRecordset3.Open "select * From reportertb1 where Name = " & strName, db, adOpenStatic, adLockOptimistic
blnisopen = True
End If
RecNo = adoRecordset3.RecordCount
Set DataGrid1.DataSource = adoRecordset3
chtSample.DataGrid.SetData 1, i, RecNo, True
chtSample.Title = frmChoiceChart.strChart
Next i
I get an error at the setting the points on the chart at the moment but im not sure if the rest of the code will work at all. Any guidance would be appreciated. Thank you