tyep mismatch

compu

Registered User.
Local time
Tomorrow, 00:09
Joined
Jul 18, 2012
Messages
22
:banghead: this thing has stumped me big time , here is my code:

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
''code:
     '' MsgBox strSQL
                   If (Combo1.Value <> " ") And (([StartDate] <> " ") Or ([EndDate] <> " ")) And ([Combo53] <> " ") Then
                    [B][U]strSQL = strSQL & " " & " WHERE Source.Day_Month_Year BETWEEN #" & [StartDate] & "# AND #" & [EndDate] & _[/U][/B]
[B][U]                            "# AND [Clusters].Cluster_Desc='" & [Combo1] & "'" And "[Source].Analysis='" & [Combo53] & "'"[/U][/B]
 
                    parSelection = [Combo1] & ";" & "Day_Month_Year:" & [StartDate] & "-" & [EndDate] & [Combo53] & ";"
                   End If
                   'Debug.Print strSQL
    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

any help would be appreciated , the part thats in bold and underlined is where i am getting the error
 
type , mismatch "13"
 
Debug.Print strSQL to view your sql statement and see where you're making mistakes.

You already have a WHERE clause in the strSQL on the second line of your entire code. You can only have one WHERE clause in an SQL statement and the order of WHERE and ORDER BY matters.
 

Users who are viewing this thread

Back
Top Bottom