Results 1 to 6 of 6
  1. #1
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70

    Expression to complex

    Hi everyone

    I am getting the follwing error and i am not even sure why. All i want is for the full Month name to appear from a start date and end date. Please note that all this information is going to be displayed in a graph.
    Code:
    SELECT Department.Dept_Desc, Count(Month([Day_Month_Year])) AS Expr1, Source.Analysis
    FROM (Department INNER JOIN (Clusters INNER JOIN Cluster_Dept ON Clusters.Cluster_ID = Cluster_Dept.Cluster_ID) ON Department.Dept_ID = Cluster_Dept.Dept_ID) INNER JOIN Source ON Cluster_Dept.ID = Source.ID
    GROUP BY Department.Dept_Desc, Source.Analysis
    HAVING (((Count(Month([Day_Month_Year]))) Between [Forms]![ViewReportsForm]![StartDate] And [Forms]![ViewReportsForm]![EndDate]));
    that's my code , help? anyone?

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Till some one come along :below is a bit puzzling,
    Code:
    HAVING (((Count(Month([Day_Month_Year]))) Between [Forms]![ViewReportsForm]![StartDate] And [Forms]!
    COUNT() BETWEEN STARTDATE AND ENDDATE.What is the value being generated by COUNT() and what are the values for filtering being passed by the form?Thanks

  3. #3
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    hi i have sorted that query out. instead of displaying the date range on the graph , i created a unbound textbox and it displays the date range there. also i am counting the number of headlines per cluster and unit.

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Glad you got things working.

    Thanks

  5. #5
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    thanks i really appreciate it , i am still getting used to this whole access thing. if you have time , i am doing this query and i get a type mismatch error

    Code:
    Private Sub Command43_Click()
    Dim strSQL As String
    'namepo = [Combo1].Value
    strSQL = "SELECT Department.Dept_Desc, Count(Source.Headline) AS NumberOfArticles, Source.Analysis " & _
             "FROM (Clusters INNER JOIN (Department INNER JOIN Cluster_Dept ON Department.Dept_ID=Cluster_Dept.Dept_ID)" & _
             "ON Clusters.Cluster_ID=Cluster_Dept.Cluster_ID) INNER JOIN Source ON Cluster_Dept.ID=Source.ID " & _
             "WHERE (((Source.Analysis)=Forms!ViewReportsForm!Combo53) And ((Source.Day_Month_Year) Between Forms!ViewReportsForm!StartDate And Forms!ViewReportsForm!EndDate) And ((Clusters.Cluster_Desc)=Forms!ViewReportsForm!Combo1)) " & _
             "GROUP BY Department.Dept_Desc, Source.Analysis"
             
             If IsNull(Combo1.Value) And IsNull([StartDate]) And IsNull([EndDate]) And IsNull([Search]) And IsNull([Combo53]) Then
                'run report without any condition
               strSQL = strSQL & ";"
             Else
                       If (Combo1.Value <> " ") And (([StartDate] <> " ") Or ([EndDate] <> " ")) And ([Combo53] <> " ") Then
                        strSQL = strSQL & " " & "WHERE Source.Day_Month_Year Between #" & [StartDate] & "# AND #" & [EndDate] & "# AND [Source].Analysis  =" & Chr(34) & [Combo53] &  Chr(34) And "&_"
                        [Clusters].Cluster_Desc = " & Chr(34) & [Combo1] & Chr(34) "
                        parSelection = [Combo1] & ";" & "Day_Month_Year:" & [StartDate] & "-" & [EndDate] & [Combo53] & ";"
                       End If
        End If
        
    '   Assign SQL code to query that the entry form uses
                 CurrentDb.QueryDefs("Query1").SQL = strSQL
                 
                'Open the report
                DoCmd.OpenReport "Report1", acViewReport
    End Sub
    thanks again

  6. #6
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Am not in to VBA, but till some one comes along, a few thoughts :

    1)
    strsql =
    "SELECT
    .......
    FROM
    ....
    WHERE
    ...
    GROUP BY
    ...."
    "
    Now, we have an IF IsNull() condition, Then we want to run the query without any condition.
    But we already have the WHERE clause before the IF.

    2) Again, was wondering about the use of ELSE IF, since to me there appears to be only one
    IF ISNULL()..... THEN
    .............
    ELSE ( here the NOT NULL )
    .............
    END IF

    3) The operation that will take place, if the ELSE condition is executed,
    strsql =
    "SELECT
    .......
    FROM
    ....
    WHERE
    ...
    GROUP BY
    ...."
    WHERE
    ........
    "

    4) Add a debug.Print strsql perhaps, just after the last End If & see what sql is getting printed in the IMMEDIATE window.
    That should perhaps give you a clue.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-07-2012, 02:59 PM
  2. Replies: 1
    Last Post: 05-24-2012, 12:34 PM
  3. Expression too complex to Evaluate
    By cbh35711 in forum Access
    Replies: 4
    Last Post: 02-27-2012, 11:06 AM
  4. Replies: 3
    Last Post: 03-31-2011, 11:07 AM
  5. need help, expression is too complex?
    By ice673 in forum Queries
    Replies: 5
    Last Post: 02-15-2010, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums