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

    type mismatch

    so i am stumped on this one , i get a type mismatch error:



    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
                       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

    the part thats bold and underlined is were i am getting the error

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Try:
    " WHERE Source.Day_Month_Year BETWEEN #" & [StartDate] & "# AND #" & [EndDate] & _
    "# AND [Source].Analysis='" & [Combo53] & "' AND [Clusters].Cluster_Desc='" & [Combo1] & "'"

    Assumes Day_Month_Year is a date/time datatype and the other fields are text type.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    sure i will give it a try now

  4. #4
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    Code:
                        strSQL = strSQL & " " & " WHERE Source.Day_Month_Year BETWEEN #" & [StartDate] & "# AND #" & [EndDate] & _
                                "# AND [Clusters].Cluster_Desc='" & [Combo1] & "'" And "[Source].Analysis='" & [Combo53] & "'"
    still getting the error

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    You have not used the exact structure I suggested. Look at the 'And' in front of Analysis. There are two extra quote marks.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. type mismatch
    By slimjen in forum Forms
    Replies: 21
    Last Post: 07-24-2012, 03:14 PM
  2. Type Mismatch....WHY?!!?
    By jgelpi16 in forum Queries
    Replies: 9
    Last Post: 03-07-2011, 09:18 AM
  3. Type Mismatch
    By Alex Motilal in forum Programming
    Replies: 10
    Last Post: 02-13-2011, 05:42 AM
  4. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM
  5. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 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