So what do you suggest Majp?
This is the entire class wrapper and the way I call it, why would this be hanging?
clsRS
Code:
Option Compare Database
Private mainRS As DAO.Recordset
Private cloneRS As DAO.Recordset
Private sQuery As String
Private db As DAO.Database
Private qd As DAO.QueryDef
Private Sub Class_Initialize()
Set db = CurrentDb
Set qd = db.QueryDefs("spPassThroughWeb")
End Sub
Public Property Get Recs() As DAO.Recordset
If cloneRS Is Nothing Then
MsgBox "Recordset is null"
End If
Set Recs = cloneRS
If (Recs.RecordCount > 0) Then
Recs.MoveLast
End If
End Property
Public Sub setQuery(spQuery As String)
If Nz(spQuery, "") = "" Then
MsgBox "Invalid query string! format : ""spName 'param1', 'param2'..."""
Else
sQuery = "EXEC " & spQuery
End If
End Sub
Public Sub setQD(spQD As String)
Set qd = db.QueryDefs(spQD)
End Sub
Public Sub Run()
If Nz(sQuery, "") = "" Then
MsgBox "Invalid query string, process aborted!"
Else
qd.SQL = sQuery
Set mainRS = qd.OpenRecordset
Set cloneRS = mainRS.Clone
End If
End Sub
Public Sub Filter(sFil As String)
Set cloneRS = mainRS.Clone
If Nz(sFil, "") <> "" Then
cloneRS.Filter = sFil
Set cloneRS = cloneRS.OpenRecordset
End If
End Sub
i then use....
Code:
Private rs As clsRS
Set rs = New clsRS
rs.setQuery "spAccountsSearch 'Paid'"
rs.Run
Set Me.accounts_search_results.Form.Recordset = rs.Recs
So far so good, all works fine... but then when the search box is used and the filter is applied
Code:
Set Forms!Accounts_Search!accounts_search_results.Form.Recordset = Nothing
DoEvents
'Company Name
If var = "Company" Then
If Nz(Me.Company.Text, "") <> "" Then
srch = "CompanyName LIKE '*" & Replace(Me.Company.Text, "'", "''") & "*'"
End If
If Not IsNull(Me.Company.Text) Then
Me.Company.value = Me.Company.Text
Me.Company.SetFocus
Me.Company.SelStart = Len(Me.Company.value)
End If
Else
If Nz(Me.Company, "") <> "" Then
srch = "CompanyName LIKE '*" & Replace(Me.Company, "'", "''") & "*'"
End If
End If
rs.Filter srch
Set Me.accounts_search_results.Form.Recordset = rs.Recs
it hangs when resetting the form's recordset!
Only if you perform a 'MoveLast' against the record set prior to altering the form's recordset does it work.
(hence adding it as part of the clsRS class)
I put debug statements throughout each operation within the class and through out the other code so I could track after each line of code was executed and prior to its execution.
Everything worked swimingly until trying to re-alter the form's recordset, then it just hung.
The 'MoveLast' fixes the problem.
Any ideas?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
MIME::Lite TLS Email Encryption - Perl v0.02 beta