Run-time error 3075

compu

Registered User.
Local time
Today, 14:21
Joined
Jul 18, 2012
Messages
22
Hi everyone i have tried so many different options but this is still not working out :banghead:. i have changed my code many times but i still get this error, Nonetheless here is my code , maybe someone will know where i am going wrong

Code:
Private Sub Command43_Click()
'namepo = [Combo1].Value
Dim strSQL As String
'
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
                    strSQL = strSQL & " " & " WHERE Source.Day_Month_Year BETWEEN #" & [StartDate] & "# AND #" & [EndDate] & _
                            "# AND [Clusters].Cluster_Desc= " & [Combo1] & " and " & "[Source].Analysis = " & [Combo53] & ""
                            
                    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


thanks again everyone
 
If you are referencing Form control values in your Query make sure you enclose them within
Code:
[COLOR=Green]" &[/COLOR] Forms!FormName!NumberControlName [COLOR=Green]& "[/COLOR]
If they are Strings then..
Code:
[COLOR=Red][B]'[/B][/COLOR][COLOR=Green]" &[/COLOR] Forms!FormName!StringControlName [COLOR=Green]& "[/COLOR][COLOR=Red][B]'[/B][/COLOR]
If they are Dates then..
Code:
[COLOR=Red][B]#[/B][/COLOR][COLOR=Green]" &[/COLOR] Forms!FormName!StringControlName [COLOR=Green]& "[/COLOR][COLOR=Red][B]#[/B][/COLOR]
 
Also you have another WHERE condition generating and concatenated to the end of the strSQL.. As far as I am aware a SQL query can have only one Where..
 
We will know what's going on if you tell us what the problem is and what you're trying to achieve compu.
 

Users who are viewing this thread

Back
Top Bottom