473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

send email on query (individual)

need to send email based on query (specific record) to specific one
I have erorr " object required " and " Object variable or with block variable not set" I do not know what is the problem
please some help
thanks



code here


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Private Sub Command0_Click()
  3. Dim mydb As DAO.Database
  4. Dim rst As DAO.Recordset
  5. Dim tempst As String
  6. Dim qdf As QueryDef
  7. Dim rest As String
  8. Dim rst2 As Recordset
  9. Dim mdatee As Date
  10. Dim mpayroll As String
  11. Dim mto As String
  12. Set mydb = CurrentDb
  13. tempst = "SELECT DISTINCT payroll, datee, email FROM payed query WHERE datee = '" & dodo & "'" & " ORDER BY payroll"
  14. Set rst = mdb.OpenRecordset(tempst, dbOpenDynaset)
  15. rst.MoveFirst
  16. While Not rst.EOF
  17. mpayroll = rst("payroll")
  18. mdatee = rst("datee")
  19. Set qdf = mydb.QueryDefs("payedQuery")
  20. rest = "SELECT payed.payroll,personal.namee,payed.type,payed.amou nt,personal.email,payed.datee" & _
  21. "FROM payed inner join personal on payed.payroll = personal.payroll" & _
  22. "WHERE payed.payroll= mpayroll, payed.datee = mdatee " & _
  23. "ORDER BY payed.payroll"
  24. qdf.SQL = rest
  25. qdf.Close
  26. Set rst2 = qdf.OpenRecordset
  27. rst2.MoveFirst
  28. 'While Not rst2.EOF
  29. mto = rst2("email")
  30. DoCmd.SendObject acSendQuery, payedQuery, acFormatXLS, mto, , , "قيمة العلاج الاسري والشخصي ", "قيمة فواتير العلاج الشخصي والاسري التى خرجت من الطبية", False
  31. rst2.Close
  32. rst2.MoveNext
  33. Wend
  34. mdb.Close
  35. End Sub 
  36.  
  37.  
May 15 '14 #1
4 1446
Seth Schrock
2,965 Expert 2GB
First error is on line 14, you declared the variable as mydb, but then used it in line 14 as mdb. This very well could account for both errors.

You will also encounter an error when your SQL string in lines 20 - 23 gets concatenated because you are missing spaces at the end of lines 20 and 21 inside the quote. You got it right on lines 22.

Also, if the field datee is a date/time field, then your line 13 will fail. You need to surround a date value with hashmarks (#) instead of the single quote (').

Give that a try and let us know what happens.
May 15 '14 #2
"syntax error " here
Expand|Select|Wrap|Line Numbers
  1. rest = "SELECT payed.payroll, personal.namee, payed.type, payed.amount, personal.email, payed.datee" &_
  2.     " FROM payed inner join personal ON payed.payroll = personal.payroll" & _
  3.     " WHERE payed.payroll = mpayroll and payed.datee = mdatee" & _
  4.     " ORDER BY payed.payroll"
May 15 '14 #3
Seth Schrock
2,965 Expert 2GB
On your first line you need a space between the ampersand and the underscore at the end of the line. You got it right on the others.
May 15 '14 #4
zmbd
5,501 Expert Mod 4TB
OK,
We are off topic now.
Per forum guidlines - we ask that each thread stay to one topic/question.
Usually a closely related follow-up or a "quick" to solve question is allowed - but now we're on to the third series of troubleshooting.


The original question was...
object required " and " Object variable or with block variable not set" I"
Appears to have been solved in Post#4


Post #5 starts a second question - as such I will be splitting the thread at that point. Second Question

Post #15 asks yet a third question... and I'll start a split there. Third Question

Please do not post any further Q&A to this thread unless it relates to the original post.
May 20 '14 #5

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

Similar topics

1
by: mhawkins19 | last post by:
I have a form built and on the onclick event I validate all of the fields and then if the form is ok, on the submit event I run a javascript function to set a cookie and download a file from the...
1
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It...
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
2
by: Ron | last post by:
hi guys, I am trying to send email using smtpMail. I can send emails inside the organization, but out of the organization I get an error "The server rejected one or more recipient addresses. The...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
2
by: ucasesoftware | last post by:
i start a process to send email via Outlook I have succes to build the email text, objet, sender... but i want to automate the "send"... i don't want my users to click on Send email button......
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
16
by: =?Utf-8?B?Q2hlZg==?= | last post by:
I can use outlook2003 to send email,but I cann't use this code below to send email. Please help me to test this code and instruct me how to solve this problem in detail. software...
7
by: mak1084 | last post by:
Hi, I want to make online registration script. To do this I searched google and found that cURL can be used, to send a query to the remote sever and getting the data back. Can you guys help me...
0
by: Mike Massaro | last post by:
Hello everyone, I'm new to PHP and creating an advertising website for massage therapists. On the profile page I'm creating a button so anyone can click on to send the advertiser an email. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.