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

    type mismatch error 13


    Hi everyone

    i know i have posted this before but i can't understand why i am getting this error:
    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
    the part thats in bold and is underlined is where i am getting my error , i have changed my code from the replies i got before but i am still getting this error

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Did you check out

    https://www.accessforums.net/queries...lex-27113.html

    specially the reference to

    1) the where clause appearing before the IF and then again appearing in the ELSE.
    and
    2) what is the result of the debug.print sql when the IF and then the ELSE gets executed.


    In addition, have you tried setting breakpoints & see what is happening.

    Thanks

  3. #3
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    i have tried that debug.print strSQL and nothing happens

  4. #4
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Debug.print outputs to the immediate pane in the vb debugger.

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

Similar Threads

  1. run-time error 13 , type mismatch
    By Compufreak in forum Programming
    Replies: 8
    Last Post: 08-13-2012, 12:17 AM
  2. Data type mismatch error
    By nigelbloomy in forum Programming
    Replies: 1
    Last Post: 08-01-2012, 09:19 AM
  3. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  4. Error#13 Type Mismatch
    By Nistin27 in forum Access
    Replies: 8
    Last Post: 08-17-2011, 04:15 PM
  5. type mismatch error?
    By hlcarlin in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 08:30 AM

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