troubleshooting Question

Dinamic Query filtering on MS/Access - circular reference

Avatar of João serras-pereira
João serras-pereiraFlag for Portugal asked on
Microsoft DevelopmentMicrosoft Access
6 Comments2 Solutions734 ViewsLast Modified:
I have a multi-record form that needs to display the result of a query. The query itself is predefined and has come computed fileds, regarding to the original tables.
However, dependeing on criteria, only some of the records are to be presented.

My current code, which I believe isw ay out of line is below:

   
    Dim IBool As Boolean
   
    Dim strUserID As String, _
        strFilterSQL As String, _
        strFilter As String
       
       
    Dim Q01_UserToDoTasksSet As DAO.Recordset
       
    Set cdiDB = CurrentDb
   
    'On Error GoTo ProcErrorFilter
   
    strUserID = Nz(Forms![F91_LoggedUser]![CurrentUserID], "")
    If strUserID <> "" Then
        strFilterSQL = "SELECT * FROM Q01_UserToDoTasks WHERE " & "[Q01_UserToDoTasks].[T15_CurrentOwnerID] = " & strUserID
    Else
        strFilterSQL = "SELECT * FROM Q01_UserToDoTasks WHERE " & "[Q01_UserToDoTasks].[T15_CurrentOwnerID] = '###Impossivel###' "
    End If
    cdiDB.QueryDefs("Q01_UserToDoTasks").SQL = strFilterSQL
    'Me.Form.RecordSource = "Q01_UserToDoTasks"
    Set Q01_UserToDoTasksDef = cdiDB.QueryDefs("Q01_UserToDoTasks")
    Set Q01_UserToDoTasksDefSet = Q01_FichasSelecionadasDef.OpenRecordset(dbOpenDynaset)
    Me.Form.Recalc
    Exit Sub
   
ProcErrorFilter:
    IBool = InsertLog("F0001 Form_Load", "Load", "", "", "", 0, 0, strUserID, "Erro em Filtro. Filtro: '" & Me.Filter & "'")
 
 
The Query is Q01_UserToDoTasks and the record source of the form (this is its load event) is linked to the query.

I am getting the aobece circular reference error and can't tell what is wrong as I am a rookie on this pprogramming

can someone help?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros