473,396 Members | 1,879 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,396 software developers and data experts.

Generate MS Outlook Task Based on Date Text Box in Access Form

11
I'd like to use a checkbox with the necessary VBA code that when checked, it would fire a MS Outlook task to the recipient based on some fields in a form that I have.

My form is called All Details. I'd like the email to be sent to the reciepient's email address that is in the cboassignedto field and have the task created based on the txtduedate_detail txt box that has the date. I'd like for the VBA code to set a reminder for 2 days if the txtduedate is greater than 2 days from today.

I really don't know where I need to get started with this task so some guidance for someone learning is much appreciated.

Thanks in advance!
Aug 4 '12 #1

✓ answered by twinnyfo

bkyzer,

I don't know if creating a task is possible, but I know you can set up appointments in VBA. Here is some sample code to get started:


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Function CreateAppointment(SubjectStr As String, BodyStr As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
  5. On Error Goto EH
  6.     Dim OlApp As Outlook.Application
  7.     Dim Appt As Outlook.AppointmentItem
  8.     Set OlApp = CreateObject("Outlook.Application")
  9.     Set Appt = OlApp.CreateItem(olAppointmentItem)
  10.     Appt.Subject = SubjectStr
  11.     Appt.Start = StartTime
  12.     Appt.End = EndTime
  13.     Appt.AllDayEvent = AllDay
  14.     Appt.BOdy = BodyStr
  15.     Appt.Save
  16.     Set Appt = Nothing
  17.     Set OlApp = Nothing
  18.     Exit Function
  19. EH:
  20.     MsgBox Err.Number & " " & Err.Description
  21.     Exit Function
  22. End Function
  23.  

You would call this Function from elsewhere within your code like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.      CreateAppointment "John Test", "This is the body", Now(), Now + 1, True
  3. End Sub
  4.  
I hope this gets you pointed in the right direction.....

4 3382
twinnyfo
3,653 Expert Mod 2GB
bkyzer,

I don't know if creating a task is possible, but I know you can set up appointments in VBA. Here is some sample code to get started:


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Function CreateAppointment(SubjectStr As String, BodyStr As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
  5. On Error Goto EH
  6.     Dim OlApp As Outlook.Application
  7.     Dim Appt As Outlook.AppointmentItem
  8.     Set OlApp = CreateObject("Outlook.Application")
  9.     Set Appt = OlApp.CreateItem(olAppointmentItem)
  10.     Appt.Subject = SubjectStr
  11.     Appt.Start = StartTime
  12.     Appt.End = EndTime
  13.     Appt.AllDayEvent = AllDay
  14.     Appt.BOdy = BodyStr
  15.     Appt.Save
  16.     Set Appt = Nothing
  17.     Set OlApp = Nothing
  18.     Exit Function
  19. EH:
  20.     MsgBox Err.Number & " " & Err.Description
  21.     Exit Function
  22. End Function
  23.  

You would call this Function from elsewhere within your code like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.      CreateAppointment "John Test", "This is the body", Now(), Now + 1, True
  3. End Sub
  4.  
I hope this gets you pointed in the right direction.....
Aug 6 '12 #2
bkyzer
11
Thanks for the insight. If Tasks are a no-go I'll try to go with this appointment option. I get that I need to put the subroutine behind my control, however, how do I need to build the Function that is your first set of code?

Thanks for the help as I'm self-taught one all of this and I wish I could do some formal training.
Aug 6 '12 #3
twinnyfo
3,653 Expert Mod 2GB
No problems.... I am completley self-taught, too. But, I do recommend taking some time to learn in a formal setting, as you will learn some of the basic principles of databases that you could only learn after much trial and error on your own....

For the first part of my code, I would place that in a separate module (I always have a module in my Access projects called modSystem, that contains all my public functions and subroutines). Then, on your form, you can set the addressees for the appointment and set other criteria for the appointment and have a command button on the form which executes the function as depicted in my second portion of code. All of the arguments for that code would be based on the text boxes on your form.

I hope this helps.
Aug 6 '12 #4

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

Similar topics

1
by: William Ortenberg | last post by:
With an Access 97 front-end, and a SQL Server 2000 back-end, I have a field on a form representing a SQL datetime column that I only want to see in a Short Date format (xx/xx/xxxx). I set the format...
0
by: William | last post by:
Hi there, Is there anybody here who ever create outlook task item from asp .net script successfully ? Actually I've created the script for creating the task, and it run successfully from the...
1
by: ielamrani | last post by:
Hi, I have a form with the following text boxes: ID name Open Date Comment. I would like to add a button to the form that opens Outlook with all the text boxes info in it. In other words,...
4
by: KPOJonesECC | last post by:
Hello, I am in the middle of an access database projet but are struggerling with a couple of things. I dont expect anyone to solve the problem for me, but would really appreciate a pointer in the...
4
by: rwm | last post by:
Hi Before updating to Access 2007 we could open outlook contact entries by using a hyperllink along the lines of <outlook://contacts etc> This does not seem to work in 2007 any more. We have a...
0
by: grant | last post by:
Has anyone got a sample db that has a form to list an Outlook inbox and subfolders? I want to be able to mimic the tree style list of folders in Outlook so the user can browse the contents on...
7
by: buddyr | last post by:
Hello, txtbox one has a date. txtbox two has a number. number is number of days) txtbox three is empty. I have alot more going on but this is my question: can I add txtbox1 + txtbox2 and show...
1
by: tymperance | last post by:
I have a 2007 database that I need to add a command button that will open a new Outlook task and allow the user to input the assignment, start date, due date, etc. I've got plenty of code scripting...
2
by: Medaron | last post by:
I am trying to wite a vba code to read all my outlook task fields in Access database. So far I have following code: Sub OutlookTasks() Dim ol As Object Dim olns As Object Dim objFolder As...
0
by: jbrumbau | last post by:
Hello, I would really like to know how to create fillable PDF files with an Access form. I know how to print a form and create a static PDF file but would like one that automatically converts...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
tracyyun
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...
0
agi2029
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 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.