StrikeEagleII
Technical User
I have a form with subform that is bound to an ADO recordset (Access 2003 to SQL Server 2008 R2). I have two buttons on the subform - one to apply a filter and one to remove it. At first, I was just using the following code to apply the filter:
The first time I do this it works great. However if I try to remove the filter by
or apply an additional filter, I get the error "Cannot Initialize Data Provider" when trying to create the recordset clone.
I also tried to set the filter by
and remove it by
where txtFilter is an unbound textbox that contains what the filter should be (i.e Owner = 'Manufacturing') but the results are the same - works great the first time and bombs everytime afterwards with the error above (and not only causes the error, but when I put the form back in design view, it causes access to crash)
Any thoughts?
Code:
intOldItem = Me.cboItemID
Set rsClone = Me.Recordset.Clone
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
rsClone.Find "[ItemID] = " & intOldItem
Me.Bookmark = rsClone.Bookmark
The first time I do this it works great. However if I try to remove the filter by
Code:
Set rsClone = Me.Recordset.Clone
DoCmd.RunCommand acCmdRemoveFilterSort
rsClone.Find "[ItemID] = " & intOldItem
Me.Bookmark = rsClone.Bookmark
or apply an additional filter, I get the error "Cannot Initialize Data Provider" when trying to create the recordset clone.
I also tried to set the filter by
Code:
intOldItem = Me.cboItemID
Me.FilterOn = False
Me.OrderByOn = False 'This was the "solution" to this problem in another forum post
Set rsClone = Me.Recordset.Clone
If Me.Filter = "" Then
Me.Filter = Me.txtFilter
Else
Me.Filter = Me.Filter & " AND " & Me.txtFilter
End If
Me.FilterOn = True
rsClone.Find "[ItemID] = " & intOldItem
Me.Bookmark = rsClone.Bookmark
and remove it by
Code:
intOldItem = Me.cboItemID
Me.FilterOn = False
Me.OrderByOn = False
Set rsClone = Me.Recordset.Clone
Me.Filter = ""
rsClone.Find "[ItemID] = " & intOldItem
Me.Bookmark = rsClone.Bookmark
where txtFilter is an unbound textbox that contains what the filter should be (i.e Owner = 'Manufacturing') but the results are the same - works great the first time and bombs everytime afterwards with the error above (and not only causes the error, but when I put the form back in design view, it causes access to crash)
Any thoughts?