View Single Post
  #1  
Old February 16th 06, 04:16 PM posted to microsoft.public.outlook.program_vba
Grant Bush
external usenet poster
 
Posts: 1
Default Importing Tasks from Access on startup

I've got some vba code setup to import tasks from an access table upon
outlook starting, but I need to add code to compare the task items to make
sure that they aren't duplicated. Below is the code that I have. I would
appreciate any help offerred and if there is a better code that should be
used, let me know.

thanks.

Grant Bush

Private Sub Application_Startup(ByVal Item As Object, Cancel As Boolean)

Dim olns As Outlook.NameSpace
Dim oltaskfolder As Outlook.MAPIFolder

Dim oltaskitem As Outlook.TaskItem

Dim objConn As ADODB.Connection
Dim objrst As ADODB.Recordset
Dim objfld As ADODB.field
Dim strsql As String

Set olns = Application.GetNamespace("MAPI")
Set oltasksfolder = olns.GetDefaultFolder(olFolderTasks)

Set objConn = CreateObject("ADODB.Connection")
Set objrst = CreateObject("ADODB.Recordset")

strsql = "SELECT * From Gbdd;"

objConn.provider = "Microsoft.jet.oledb.4.0"
objConn.Open "I:\bush\rockford ehs.mdb"

objrst.Open strsql, objConn, adopenforwardonly, adlockoptimistic

objrst.movefirst

While Not objrst.EOF
Set oltaskitem = oltasksfolder.Items.Add("IPM.task")
oltaskitem.Display
oltaskitem.Subject = objrst.Fields("Description")
oltaskitem.DueDate = objrst.Fields("compliance due date")
oltaskitem.ReminderTime = objrst.Fields("reminder date")
' oltaskitem.Notes = objrst.Fields("plant affected")
' oltaskitem.Status = objrst.Fields("status")
objrst.movenext
oltaskitem.Close olSave
Wend

objrst.Close
objConn.Close

Set objrst = Nothing
Set objConn = Nothing
Set olctitem = Nothing
Set objprospectfolder = Nothing
Set objctfolder = Nothing
Set objns = Nothing



End Sub
Ads