Hi Guys, I have a large table in a database.I would like to populate a datagrid so that rows can be selected by scrolling. This would be too large.
I therefore have 5 option buttons for which i will create 5 recordset that i need to load into a datagrid depending on selection. I am doing this to reduce the size of the datagrid that needs to be scrolled.
I know the buttons are in an array but how do you point to the correct recordset. Is this the correct way of going about it?
'the option array
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0:
Case 1:
Case 2:
Case 3:
Case 4:
End Select
End Sub
'the recordset
Private Sub Form_Load()
Set selectStock = New ADODB.Connection
selectStock.ConnectionString = _
"Provider = Microsoft.Jet.OLEDB.4.0; Data Source=C:\My Documents\GP project\gpframings.mdb"
selectStock.Open
Set rsSelect = New ADODB.Recordset
selectSql = "Select stockcode, stockdescription, price From stock Where category = glass"
'stockRS.Source = rSql
With rsSelect
.ActiveConnection = selectStock
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open selectSql
End With
If rsSelect.BOF = True Or rsSelect.EOF = True Then
Exit Sub
End If
Set DataGrid1.DataSource = rsSelect
DataGrid1.Refresh
End Sub
'Cheers!!
I therefore have 5 option buttons for which i will create 5 recordset that i need to load into a datagrid depending on selection. I am doing this to reduce the size of the datagrid that needs to be scrolled.
I know the buttons are in an array but how do you point to the correct recordset. Is this the correct way of going about it?
'the option array
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0:
Case 1:
Case 2:
Case 3:
Case 4:
End Select
End Sub
'the recordset
Private Sub Form_Load()
Set selectStock = New ADODB.Connection
selectStock.ConnectionString = _
"Provider = Microsoft.Jet.OLEDB.4.0; Data Source=C:\My Documents\GP project\gpframings.mdb"
selectStock.Open
Set rsSelect = New ADODB.Recordset
selectSql = "Select stockcode, stockdescription, price From stock Where category = glass"
'stockRS.Source = rSql
With rsSelect
.ActiveConnection = selectStock
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open selectSql
End With
If rsSelect.BOF = True Or rsSelect.EOF = True Then
Exit Sub
End If
Set DataGrid1.DataSource = rsSelect
DataGrid1.Refresh
End Sub
'Cheers!!