I am currently using this code to send an appointment to Outlook. It sends the info to a form called "frmAppointments" and then to Outlook. This code works great to send the record that is in focus. I would like to be able to have the ability to send multiple records as appointments. How do I do more than one at a time? - Form_frmAppointments!ApptDate = [Form_Maintenance Subform3].[Next Maintenance]
-
'Form_frmAppointments!ApptTime = Me![Sample Run Time]
-
Form_frmAppointments!Appt = Me.Text80
-
Form_frmAppointments!ApptReminder = True
-
-
-
-
' Save record first to be sure required fields are filled.
-
DoCmd.RunCommand acCmdSaveRecord
-
' Exit the procedure if appointment has been added to Outlook.
-
-
Dim outobj As Outlook.Application
-
Dim outappt As Outlook.AppointmentItem
-
Set outobj = CreateObject("outlook.application")
-
Set outappt = outobj.CreateItem(olAppointmentItem)
-
With outappt
-
.Start = Form_frmAppointments!ApptDate & " " & Form_frmAppointments!ApptTime
-
.Duration = Form_frmAppointments!ApptLength
-
.Subject = Form_frmAppointments!Appt
-
.Categories = "Maintenance"
-
If Not IsNull(Form_frmAppointments!ApptNotes) Then .Body = Form_frmAppointments!ApptNotes
-
If Not IsNull(Form_frmAppointments!ApptLocation) Then .Location = _
-
Form_frmAppointments!ApptLocation
-
If Form_frmAppointments!ApptReminder Then
-
.ReminderMinutesBeforeStart = Form_frmAppointments!ReminderMinutes
-
.ReminderSet = True
-
End If
-
.Save
-
End With
-
' Release the Outlook object variable.
-
Set outobj = Nothing
-
' Set the AddedToOutlook flag, save the record, display a message.
-
Form_frmAppointments!AddedToOutlook = True
-
DoCmd.RunCommand acCmdSaveRecord
-
MsgBox "Appointment Added!"
-
Exit Sub
-
AddAppt_Err:
-
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
-
Exit Sub
7 4164 ADezii 8,834
Recognized Expert Expert
This is just Theory, I haven't actually tested it. - Create a Recordset which consists of only those Records that you wish to Send to Outlook.
- Loop through each Record, sending the appropriate Data by referencing the Fields in the Recordset.
- If you are not sure how to do this, I can point you in the right direction.
I have a subform that has all the maintenance records on it filtered according to the Equipment item on the main form. Right now I can click a button on the main form and send the infocus maintenance record from the subform to Outlook as an appointment. How would I loop through the record set to tell Access to send all of the filtered records on the subform to Outlook? I don't know how to create a "loop".
ADezii 8,834
Recognized Expert Expert - Create a Recordset based on the Current State of the Sub-Form, as in it's Recordset Property.
- Loop through all the Records in the Recordset, performing some operation on each Record, in your case sending specific Data to Outlook.
- I created a Demo for you based on the Orders Form of the Northwind Sample Database. This Form contains a Sub-Form named Orders Subform. For any given Record in the Main Form (Orders), the Code will loop through through all related Records in the Sub-Form and Print specific Field Values.
- Dim rst As DAO.Recordset
-
-
Set rst = Me![Orders Subform].Form.RecordsetClone
-
rst.MoveFirst
-
-
Debug.Print "[ProductID]", "[Quantity]", "[UnitPrice]", "[Discount]", "[ExtendedPrice]"
-
-
With rst
-
Do While Not .EOF
-
'Process Fields for Outlook here
-
Debug.Print ![ProductID], ![Quantity], ![UnitPrice], ![Discount], ![ExtendedPrice]
-
.MoveNext
-
Loop
-
End With
-
-
rst.Close
-
Set rst = Nothing
OUTPUT: - [ProductID] [Quantity] [UnitPrice] [Discount] [ExtendedPrice]
-
59 15 55 0.1 742.5
-
57 5 19.5 0.1 87.75
-
40 10 18.4 0.1 165.6
-
11 50 21 0.1 945
ADezii, thanks. I guess I am just not quite understanding what I am suppose to do with this code. Is it suppose to work in conjunction with the code to send an appointment to Outlook? I placed this code you gave me behind a button on the Orders form of the Northwind database, but nothing happens when I click it. Thanks for the puzzle piece I just don't know where to put it. =-)
ADezii 8,834
Recognized Expert Expert
When I get a chance, I'll try to Merge this Code with your Outlook Code to give you some idea as to how you can process the Records in the Sub-Form. The General Idea is as follows: - Dim outobj As Outlook.Application
-
Dim outappt As Outlook.AppointmentItem
-
Set outobj = CreateObject("outlook.application")
-
Set outappt = outobj.CreateItem(olAppointmentItem)
-
Dim rst As DAO.Recordset
-
-
Set rst = Me![Orders Subform].Form.RecordsetClone 'Sub-Form's Recordset
-
rst.MoveFirst
-
-
-
With outappt
-
Do While Not rst.EOF 'Process Records in the Recordset (Sub-Form)
-
.Start = rst!ApptDate & " " & rst!ApptTime
-
.duration = rst!ApptLength
-
.Subject = rst!Appt
-
Categories = "Maintenance"
-
If Not IsNull(rst!ApptNotes) Then .Body = rst!ApptNotes
-
If Not IsNull(rst!ApptLocation) Then .Location = rst!ApptLocation
-
If rst!ApptReminder Then
-
.ReminderMinutesBeforeStart = rst!ReminderMinutes
-
.ReminderSet = True
-
End If
-
.Save
-
rst.MoveNext 'Move to the Next Record
-
Loop
-
End With
-
-
' Release the Outlook object variable.
-
Set outobj = Nothing
-
-
rst.Close
-
Set rst = Nothing
"When I get a chance, I'll try to Merge this Code with your Outlook Code"... Thanks. I see on line #25 is where you put "loop". I don't believe I have ever used the loop function before. I am very interested in seeing how it would work with my actual project and then hopefully from that be able to know how to use it in other areas. Thank You.
I think I can better articulate what I would like to see happen. I have a maintenance database with a main form based on equipment and a subform showing all the maintenance done to the specific equipment. I am currently able to send an appointment to outlook for one record of the subform at a time by clicking a button on the main form with my send to outlook code behind it. The record is first passed to a form call frmAppointments and then to Outlook. Instead of having to select each record and then send it, I would like to be able to send all the records that are for the month with just one click. Hope this helps.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ian |
last post by:
Hi,
I'm a newbie (oh no I can here you say.... another one...)
How can I get Python to send emails using the default windows email
client (eg outlook express)?
I thought I could just do the...
|
by: CS |
last post by:
Dear all,
I would like to know whether it is possible to send multiple files in 1 fax?
I noticed from some sample code, I can only specify 1 faxdocument.body in the
code. Is there a workaround?...
|
by: trint |
last post by:
Instead of just sending one document at a time, I need to send multiple
documents as a print job because our laserprinter will only stack and
staple one printjob it receives at a time.
I need to...
|
by: Barkster |
last post by:
I'm trying to send using outlook but I get an error on the directcast line
if I don't have outlook open. Works fine if it is open. What do I need to
do to be able to send without having outlook...
|
by: roni |
last post by:
i dont like to use ocx controlx.
is there new dll for vb.net that do the job ? or newer code, to send email
throught outlook express.
| |
by: Senthilkumar |
last post by:
Hi,
I would like to send mail using Outlook or Outlook Express my .net program
which is written using vb.net . When ever a new record of particular type is
added, i would like to send an...
|
by: Tidan |
last post by:
Hi,
I would like to send mail using Outlook Express my .net program
which is written using vb.net 2.0. When ever a new record of particular
type is
added, i would like to send an automatic mail...
|
by: Bibin |
last post by:
I want to send email via Outlook Express and not by Outlook in VB.NET (windows application). I also want to attach files with the email. The mail (in Outlook Express) needs to be displayed before...
|
by: kashib |
last post by:
What I am looking for is a C# example that can send multiple documents of different formats (eg pdf, doc, docx, jpeg etc)to the printer as one print job, I am not sure of the best approach. Can you...
|
by: londres9b |
last post by:
I want to send multiple emails from php with one unique script.
The emails are from a mysql database table.
How can I achieve this?
|
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,...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |