B
Blogd_Node
Hi,
Config is XP SP2 / Access 2003 / Outlook 2003
Access Refs are VBA / Access 11 / SafeOutlook / DAO 3.6 / Outlook 11 /
Calendar 11
I want to add an Outlook Task from Access.
The problem is Outlook crashes (sometimes) if not open.
Any thoughts about where I'm going wrong ?
( I know just enough VB code to be a danger to myself... )
Many thanks...
David
(Some Access code below has been snipped for clarity...)
'CODE ===============================================
Private Sub cmdCreateTask_Click()
On Error GoTo Err_cmdCreateTask_Click
Dim objOL As Object
Dim myItem As Object
Dim objSafeTaskItem As Redemption.SafeTaskItem
Dim myNS As NameSpace
Dim timeX As String
Dim strVia As String
Dim strReg As String
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
'If outlook is not running, then
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Application")
Set myNS = objOL.GetNamespace("MAPI")
myNS.Logon
End If
On Error GoTo 0
' Set up Outlook Objects.
' If there is a date set
If Len(Me!ChaseDateCalendar & "") > 0 Then
Set myItem = objOL.CreateItem(olTaskItem) 'Outlook Task Item
Set objSafeTaskItem = CreateObject("Redemption.safeTaskItem")
objSafeTaskItem.Item = myItem
With objSafeTaskItem
.Subject = Format(Me!ChaseDate, "dd-mmm-yy") & " ChaseUp " &
Trim(Me![FirstName]) & " " & _
Trim(Me![Surname]) & " " & "Via: " & Trim(strVia) & " " & _
"Re: <" & Trim(Me![cmbRegarding]) & "> " & Trim(Me![txtAddedNote])
Me!Memo = Me!Memo & vbCrLf & .Subject
.Body = "Add any comments about this chaseup into DATABASE - not
here"
.ReminderSet = True
'Remind at 9AM
.ReminderTime = FormatDateTime(timeX, 4)
'Due at selected date
.DueDate = Format(Me!ChaseDate, "dd-mmm-yy")
.ReminderPlaySound = True
'Modify path.
'.ReminderSoundFile = "C:\WINNT\Media\Ding.wav"
.Save
End With
Else
MsgBox "No ChaseUp Date set?"
End If
Exit_cmdCreateTask_Click:
Set objSafeTaskItem = Nothing
Set objOL = Nothing
Exit Sub
Err_cmdCreateTask_Click:
MsgBox Err.Description
Resume Exit_cmdCreateTask_Click
End Sub
Config is XP SP2 / Access 2003 / Outlook 2003
Access Refs are VBA / Access 11 / SafeOutlook / DAO 3.6 / Outlook 11 /
Calendar 11
I want to add an Outlook Task from Access.
The problem is Outlook crashes (sometimes) if not open.
Any thoughts about where I'm going wrong ?
( I know just enough VB code to be a danger to myself... )
Many thanks...
David
(Some Access code below has been snipped for clarity...)
'CODE ===============================================
Private Sub cmdCreateTask_Click()
On Error GoTo Err_cmdCreateTask_Click
Dim objOL As Object
Dim myItem As Object
Dim objSafeTaskItem As Redemption.SafeTaskItem
Dim myNS As NameSpace
Dim timeX As String
Dim strVia As String
Dim strReg As String
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
'If outlook is not running, then
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Application")
Set myNS = objOL.GetNamespace("MAPI")
myNS.Logon
End If
On Error GoTo 0
' Set up Outlook Objects.
' If there is a date set
If Len(Me!ChaseDateCalendar & "") > 0 Then
Set myItem = objOL.CreateItem(olTaskItem) 'Outlook Task Item
Set objSafeTaskItem = CreateObject("Redemption.safeTaskItem")
objSafeTaskItem.Item = myItem
With objSafeTaskItem
.Subject = Format(Me!ChaseDate, "dd-mmm-yy") & " ChaseUp " &
Trim(Me![FirstName]) & " " & _
Trim(Me![Surname]) & " " & "Via: " & Trim(strVia) & " " & _
"Re: <" & Trim(Me![cmbRegarding]) & "> " & Trim(Me![txtAddedNote])
Me!Memo = Me!Memo & vbCrLf & .Subject
.Body = "Add any comments about this chaseup into DATABASE - not
here"
.ReminderSet = True
'Remind at 9AM
.ReminderTime = FormatDateTime(timeX, 4)
'Due at selected date
.DueDate = Format(Me!ChaseDate, "dd-mmm-yy")
.ReminderPlaySound = True
'Modify path.
'.ReminderSoundFile = "C:\WINNT\Media\Ding.wav"
.Save
End With
Else
MsgBox "No ChaseUp Date set?"
End If
Exit_cmdCreateTask_Click:
Set objSafeTaskItem = Nothing
Set objOL = Nothing
Exit Sub
Err_cmdCreateTask_Click:
MsgBox Err.Description
Resume Exit_cmdCreateTask_Click
End Sub