Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send a task request to a variable recipient

Status
Not open for further replies.

valmatic

IS-IT--Management
Mar 30, 2006
14
US
I have a few different on-click events that send a task to a specific address, based on MSDN help:
_______________________________________
Private Sub Ass2_Click()
On Error GoTo Err_Ass2_Click

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("Marty")
myItem.Subject = "CAPA #" & CAPA_No & " has been assigned to you" & _
" This CAPA is due on " & [Section_III_Due_Date]

myItem.ReminderSet = True
myItem.DueDate = [Section_III_Due_Date]
myItem.Send

[Completed On Time?] = "Pending"

Exit_Ass2_Click:
Exit Sub

Err_Ass2_Click:
MsgBox Err.Description
Resume Exit_Ass2_Click

End Sub
____________________________________

I need to know how to add a variable recipient based on a field in my form. User selects recipient from drop down list in a separate field (Assigned To) and I need to get that result into this code to send the task request to that recipient. I've tried changing code a bunch of different ways with no luck. This is my 1st try at programming btw- so I'm totally lost to begin with:)...
 
Just reference your drop down list:
Code:
...
Set myDelegate = myItem.Recipients.Add(Me.[i][Assign To][/i])
...
Where [Assign To] is the actual name of your control.

Hope this helps,
CMP

[small]P.S. If that is your real drop down list name, I would recomend NOT putting spaces in your control names. Spaces can lead to big headaches at every step.[/small]

(GMT-07:00) Mountain Time (US & Canada)
 
omg - I can't believe it's that simple. Worked great. Thank you so much. Just so I understand though, what does the "Me." statement do exactly or a link to an explanation would be great. I did a quick google and an explanation didn't really pop up quickly.
 
[tt]Me.[/tt] just referes to the active object (Form, Report, ...) and makes your code run faster because Access does not bother looking at other objects to find what your refering to.

Also when your writting code it should cause the Fly Out listing of controls in your Form (or report...) to appear so you don't have to type as much (and I make less syntax errors because of it).

If you want more details check out the Help file.

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top