problem now "data type mismatch in criteria expression"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ihere3010
    New Member
    • May 2014
    • 9

    problem now "data type mismatch in criteria expression"

    thanks for replying
    the problem now "data type mismatch in criteria expression"
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    On which line do you get this error?

    Comment

    • ihere3010
      New Member
      • May 2014
      • 9

      #3
      Set rst = mydb.OpenRecord set(tempst, dbOpenDynaset)

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        At the top of your code, right below the OPTION COMPARE DATABASE, enter OPTION EXPLICIT. Then, click on the Debug menu and select Compile (top option I think). This will hopefully spot some errors in the code that would be very difficult to otherwise find. Then, if you could post what you have now, it would be very helpful.

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #5
          I'm not sure if there is a translation error or what, but most of what I'm seeing isn't english, so I have no idea how to fix the problem. I can link you to the MSDN website that deals with the DoCmd.SendObjec t command. If you have any questions about it, feel free to ask. DoCmd.SendObjec t Method

          Comment

          • ihere3010
            New Member
            • May 2014
            • 9

            #6
            I changed it completely and now i have problem " data type mismatch in criteria expression " at
            Set rest = mydb.OpenRecord set(temp, dbOpenDynaset)


            Code:
            Private Sub Command2_Click()
            Dim mydb As DAO.Database
            Dim rest As Recordset
            Dim temp As String
            Dim mpayroll As String
            Dim mpage As String
            Dim sqlstring As String
            Dim qdf As QueryDef
            Dim reset As Recordset
            Dim mmail As String
            
            
            Set mydb = CurrentDb
            temp = " SELECT DISTINCT payroll, page FROM pay WHERE page = '" & scode & "'" & " ORDER BY payroll"
            Set rest = mydb.OpenRecordset(temp, dbOpenDynaset)
            rest.MoveFirst
            While Not rest.EOF
             
            mpayroll = rest("payroll")
            mpage = rest("page")
            sqlstring = " SELECT payed2.payroll, payed2.type, payed1.page, payed2.amount, personal.namee, personl.email" & _
                        " FROM payed2 INNER JOIN payed1 ON payed2.page = payed1.page, INNER JOIN personal ON payed2.payroll = personal.payroll" & _
                        " WHERE payed2.payroll =  '" & mpayroll & "' And payed2.Page = " & mpage & "" & _
                        " ORDER BY payed2.payroll "
                        
            qdf.SQL = sqlstring
            qdf.Close
            
            Set reset = qdf.OpenRecordset
            reset.MoveFirst
            mmail = ("email")
            reset.Close
            DoCmd.SendObject acSendQuery, "pay", acFormatXLS, mmail, , , "here balance", " your balance here", False
            rest.MoveNext
            Wend
            MsgBox "EMAIL PROCESS COMPLETE", vbInformation
            
            mydb.Close
            
            End Sub

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #7
              On line 14, is "scode" a text data type?

              Comment

              • zmbd
                Recognized Expert Moderator Expert
                • Mar 2012
                • 5501

                #8
                POST#6
                Line 3 Dim rest As Recordset
                CHANGE TO
                Line 3 Dim rest As DAO.Recordset
                Last edited by zmbd; May 20 '14, 11:18 PM.

                Comment

                • ihere3010
                  New Member
                  • May 2014
                  • 9

                  #9
                  ok
                  scode is text box I searched in it about page " number" to limit set of records

                  Comment

                  • Seth Schrock
                    Recognized Expert Specialist
                    • Dec 2010
                    • 2965

                    #10
                    Try making line 14 be
                    Code:
                    temp = " SELECT DISTINCT payroll, page FROM pay WHERE page = " & Me.scode & " ORDER BY payroll"

                    Comment

                    • zmbd
                      Recognized Expert Moderator Expert
                      • Mar 2012
                      • 5501

                      #11
                      This thread was split from http://bytes.com/topic/access/answer...ery-individual

                      It appears that this thread was answered at Post#10

                      Another question was then asked in the following post, I have split this thread at that point.

                      Please do not post any further Q&A to this thread unless it is related to the first posting.
                      Last edited by zmbd; May 20 '14, 10:23 PM.

                      Comment

                      Working...