
Recordset Change Code Yeilds Error or All Records
This morning I received a
Visual Basic tip from the list server I am
subscribed to indicating that using .refresh on a grid bound to an data
control does not work due to a bug in VB6 SP3 (what I have). Using the code
in the tip I was able to fix the problem. The revised sub rountine is as
follows:
Sub SetupDataControl()
'define variables
Dim FilterString As String
'intialize variables
FilterString = "Domain = " & "'" & cboDomains.Text & "'"
'change recordset of adocPopAccounts to show pop accounts for selected
domain
adocPopAccounts.CommandType = adCmdText
adocPopAccounts.Recordset.Filter = FilterString
adocPopAccounts.Recordset.Requery
Set dbgrdPopAccounts.DataSource = adocPopAccounts
End Sub
The secret is to requery the recordset of the adoc control and rebind it to
the data grid after updating it to include the correct records.