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 - Option Compare Database
-
Private Sub Command0_Click()
-
Dim mydb As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim tempst As String
-
Dim qdf As QueryDef
-
Dim rest As String
-
Dim rst2 As Recordset
-
Dim mdatee As Date
-
Dim mpayroll As String
-
Dim mto As String
-
Set mydb = CurrentDb
-
tempst = "SELECT DISTINCT payroll, datee, email FROM payed query WHERE datee = '" & dodo & "'" & " ORDER BY payroll"
-
Set rst = mdb.OpenRecordset(tempst, dbOpenDynaset)
-
rst.MoveFirst
-
While Not rst.EOF
-
mpayroll = rst("payroll")
-
mdatee = rst("datee")
-
Set qdf = mydb.QueryDefs("payedQuery")
-
rest = "SELECT payed.payroll,personal.namee,payed.type,payed.amou nt,personal.email,payed.datee" & _
-
"FROM payed inner join personal on payed.payroll = personal.payroll" & _
-
"WHERE payed.payroll= mpayroll, payed.datee = mdatee " & _
-
"ORDER BY payed.payroll"
-
qdf.SQL = rest
-
qdf.Close
-
Set rst2 = qdf.OpenRecordset
-
rst2.MoveFirst
-
'While Not rst2.EOF
-
mto = rst2("email")
-
DoCmd.SendObject acSendQuery, payedQuery, acFormatXLS, mto, , , "قيمة العلاج الاسري والشخصي ", "قيمة فواتير العلاج الشخصي والاسري التى خرجت من الطبية", False
-
rst2.Close
-
rst2.MoveNext
-
Wend
-
mdb.Close
-
End Sub
-
-
4 1447
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.
"syntax error " here - rest = "SELECT payed.payroll, personal.namee, payed.type, payed.amount, personal.email, payed.datee" &_
-
" FROM payed inner join personal ON payed.payroll = personal.payroll" & _
-
" WHERE payed.payroll = mpayroll and payed.datee = mdatee" & _
-
" ORDER BY payed.payroll"
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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,...
|
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...
|
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...
|
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......
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |