By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

problem now "data type mismatch in criteria expression"

P: 9
thanks for replying
the problem now "data type mismatch in criteria expression"
May 15 '14 #1
Share this Question
Share on Google+
10 Replies


Seth Schrock
Expert 2.5K+
P: 2,951
On which line do you get this error?
May 15 '14 #2

P: 9
Set rst = mydb.OpenRecordset(tempst, dbOpenDynaset)
May 15 '14 #3

Seth Schrock
Expert 2.5K+
P: 2,951
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.
May 15 '14 #4

Seth Schrock
Expert 2.5K+
P: 2,951
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.SendObject command. If you have any questions about it, feel free to ask. DoCmd.SendObject Method
May 16 '14 #5

P: 9
I changed it completely and now i have problem " data type mismatch in criteria expression " at
Set rest = mydb.OpenRecordset(temp, dbOpenDynaset)


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2. Dim mydb As DAO.Database
  3. Dim rest As Recordset
  4. Dim temp As String
  5. Dim mpayroll As String
  6. Dim mpage As String
  7. Dim sqlstring As String
  8. Dim qdf As QueryDef
  9. Dim reset As Recordset
  10. Dim mmail As String
  11.  
  12.  
  13. Set mydb = CurrentDb
  14. temp = " SELECT DISTINCT payroll, page FROM pay WHERE page = '" & scode & "'" & " ORDER BY payroll"
  15. Set rest = mydb.OpenRecordset(temp, dbOpenDynaset)
  16. rest.MoveFirst
  17. While Not rest.EOF
  18.  
  19. mpayroll = rest("payroll")
  20. mpage = rest("page")
  21. sqlstring = " SELECT payed2.payroll, payed2.type, payed1.page, payed2.amount, personal.namee, personl.email" & _
  22.             " FROM payed2 INNER JOIN payed1 ON payed2.page = payed1.page, INNER JOIN personal ON payed2.payroll = personal.payroll" & _
  23.             " WHERE payed2.payroll =  '" & mpayroll & "' And payed2.Page = " & mpage & "" & _
  24.             " ORDER BY payed2.payroll "
  25.  
  26. qdf.SQL = sqlstring
  27. qdf.Close
  28.  
  29. Set reset = qdf.OpenRecordset
  30. reset.MoveFirst
  31. mmail = ("email")
  32. reset.Close
  33. DoCmd.SendObject acSendQuery, "pay", acFormatXLS, mmail, , , "here balance", " your balance here", False
  34. rest.MoveNext
  35. Wend
  36. MsgBox "EMAIL PROCESS COMPLETE", vbInformation
  37.  
  38. mydb.Close
  39.  
  40. End Sub
  41.  
May 18 '14 #6

Seth Schrock
Expert 2.5K+
P: 2,951
On line 14, is "scode" a text data type?
May 19 '14 #7

zmbd
Expert Mod 5K+
P: 5,397
POST#6
Line 3 Dim rest As Recordset
CHANGE TO
Line 3 Dim rest As DAO.Recordset
May 19 '14 #8

P: 9
ok
scode is text box I searched in it about page " number" to limit set of records
May 19 '14 #9

Seth Schrock
Expert 2.5K+
P: 2,951
Try making line 14 be
Expand|Select|Wrap|Line Numbers
  1. temp = " SELECT DISTINCT payroll, page FROM pay WHERE page = " & Me.scode & " ORDER BY payroll"
May 20 '14 #10

zmbd
Expert Mod 5K+
P: 5,397
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.
May 20 '14 #11

Post your reply

Sign in to post your reply or Sign up for a free account.