A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Import Outlook Task Form Data Into Access



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 14th 07, 10:27 PM posted to microsoft.public.outlook.program_vba
Donald Fisher
external usenet poster
 
Posts: 7
Default Import Outlook Task Form Data Into Access

I have several public task folders from which I would like to import the
task information into Access including some form data. I've tried the
table linking deal but it doesn't include the start date and other form
data. I know the EntryIDs and StoreIDs but can't figure out how to make
it import. Any ideas? Here's my current code:


' Set up DAO objects (uses existing "tblTasks" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblTasks")


' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.TaskItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim txtEntryID, txtStoreID

txtEntryID = Screen.ActiveForm.ENTRYID
txtStoreID = Screen.ActiveForm.STOREID

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetFolderFromID(txtEntryID, txtStoreID)
Set objItems = cf.Items
iNumTasks = objItems.Count
If iNumTasks 0 Then
For i = 1 To iNumTasks
If TypeName(objItems(i)) = "TaskItem" Then
Set c = objItems(i)
rst.AddNew
rst!TASK = c.Subject
rst!DueDate = c.DueDate
rst!STARTDATE = c.STARTDATE
rst!Status = c.Status
rst!Rec = c.IsRecurring
rst!SECTION = Screen.ActiveForm.DutySection
rst!Remarks = c.Body
rst.Update
End If
Next i
rst.Close
End If

After the last rst! I would like to add a reference to a field on a
custom tab: (There's the 'TASK' tab and 'MY TAB')

rst!EQUIPID = c.MyCustomTab.EQUIPID (or whatever will work)

Any ideas?
  #2  
Old August 14th 07, 11:00 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Import Outlook Task Form Data Into Access

If you want access to any custom fields you've created, you can get at them
via the TaskItem.UserProperties collection. To get a UserProperty object:

Dim objUP As UserProperty

Set objUP = myTaskItem.UserProperties("MyCustomFieldName")
Debug.Print objUP.Value

Does that answer your question?

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Donald Fisher" wrote:

I have several public task folders from which I would like to import the
task information into Access including some form data. I've tried the
table linking deal but it doesn't include the start date and other form
data. I know the EntryIDs and StoreIDs but can't figure out how to make
it import. Any ideas? Here's my current code:


' Set up DAO objects (uses existing "tblTasks" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblTasks")


' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.TaskItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim txtEntryID, txtStoreID

txtEntryID = Screen.ActiveForm.ENTRYID
txtStoreID = Screen.ActiveForm.STOREID

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetFolderFromID(txtEntryID, txtStoreID)
Set objItems = cf.Items
iNumTasks = objItems.Count
If iNumTasks 0 Then
For i = 1 To iNumTasks
If TypeName(objItems(i)) = "TaskItem" Then
Set c = objItems(i)
rst.AddNew
rst!TASK = c.Subject
rst!DueDate = c.DueDate
rst!STARTDATE = c.STARTDATE
rst!Status = c.Status
rst!Rec = c.IsRecurring
rst!SECTION = Screen.ActiveForm.DutySection
rst!Remarks = c.Body
rst.Update
End If
Next i
rst.Close
End If

After the last rst! I would like to add a reference to a field on a
custom tab: (There's the 'TASK' tab and 'MY TAB')

rst!EQUIPID = c.MyCustomTab.EQUIPID (or whatever will work)

Any ideas?

  #3  
Old August 14th 07, 11:52 PM posted to microsoft.public.outlook.program_vba
Donald Fisher
external usenet poster
 
Posts: 7
Default Import Outlook Task Form Data Into Access

And how would I list everything in the userproperties collection? I
don't know what some of the custom field names are and design view of
the form has been password protected.

Eric Legault [MVP - Outlook] wrote:
If you want access to any custom fields you've created, you can get at them
via the TaskItem.UserProperties collection. To get a UserProperty object:

Dim objUP As UserProperty

Set objUP = myTaskItem.UserProperties("MyCustomFieldName")
Debug.Print objUP.Value

Does that answer your question?

  #4  
Old August 15th 07, 04:18 AM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Import Outlook Task Form Data Into Access

You can loop through all custom fields programmatically by iterating through
the UserProperties collection:

For intX = 1 To MyTaskItem.UserProperties.Count
Set objUP = MyTaskItem.UserProperties.Item(intX)
Debug.Print "Field Name: " & objUP.Name & "; Value: " & objUP.Value
Next

You can also see these in the folder where the form is published. Bring up
the Field Chooser dialog and see if the form name is listed in the dropdown.
If not, browse the list and select Forms... and add your form to the folder.
You can then select the form name and see the list of fields.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Donald Fisher" wrote:

And how would I list everything in the userproperties collection? I
don't know what some of the custom field names are and design view of
the form has been password protected.

Eric Legault [MVP - Outlook] wrote:
If you want access to any custom fields you've created, you can get at them
via the TaskItem.UserProperties collection. To get a UserProperty object:

Dim objUP As UserProperty

Set objUP = myTaskItem.UserProperties("MyCustomFieldName")
Debug.Print objUP.Value

Does that answer your question?


  #5  
Old August 15th 07, 12:14 PM posted to microsoft.public.outlook.program_vba
Donald Fisher
external usenet poster
 
Posts: 7
Default Import Outlook Task Form Data Into Access

Great! Didn't realize the Field Chooser could do that. Thanks!

Eric Legault [MVP - Outlook] wrote:
You can loop through all custom fields programmatically by iterating through
the UserProperties collection:

For intX = 1 To MyTaskItem.UserProperties.Count
Set objUP = MyTaskItem.UserProperties.Item(intX)
Debug.Print "Field Name: " & objUP.Name & "; Value: " & objUP.Value
Next

You can also see these in the folder where the form is published. Bring up
the Field Chooser dialog and see if the form name is listed in the dropdown.
If not, browse the list and select Forms... and add your form to the folder.
You can then select the form name and see the list of fields.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Outlook Task Form Data Into Access Donald Fisher Outlook - General Queries 2 August 15th 07 04:52 PM
form data in outlook web access JP Outlook - Using Forms 2 May 11th 07 07:03 AM
Import data from MS Access into Outlook JRSNHECI Outlook - Using Contacts 0 January 16th 07 06:43 PM
Customized Task form not saving data RClauss Outlook - Using Forms 3 October 25th 06 04:46 PM
getting data from Access Database in Outlook Form Weatherman Outlook - Calandaring 1 April 17th 06 02:49 PM


All times are GMT +1. The time now is 12:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.