Disclaimer: I'm not an Access or VB guy, at all. I'm trying to troubleshoot a database for a client and I really have no idea what I'm looking at. With that said...
I'm trying to change the date entry for a record and I keep getting a Run-time Error.
Specific error below:
Run-time error '-2147221233 (8004010f)':
The attempted operation failed. An object could not be found.
I click the DEBUG button and get the line in red highlighted.
Code:
Private Sub eraseapp(dateapp As Date, subjectapp As String)
Dim strFind
Dim objAppt1
Dim olappointment As Outlook.AppointmentItem
'Using object rather than MailItem, so that it
'can handle posts, meeting requests, etc as well
Dim olExp As Outlook.Explorer
Dim calendarFolder As Outlook.MAPIFolder
'Dim olApp As Outlook.Application
Dim colCalendar
'Set olApp = Outlook.CreateObject("Outlook.Application")
If Not InitializeOutlook Or olApp Is Nothing Then
MsgBox "There was an error initializating outlook"
Else 'if it is not able to initalizate outlook it will not create the appointment
Set olExp = olApp.ActiveExplorer
Set calendarFolder = olApp.GetNamespace("MAPI").Folders("Public Folders").Folders("All Public Folders").Folders("Bid Calendar")
'Set calendarFolder = olApp.GetNamespace("MAPI").GetDefaultFolder(9)
Set colCalendar = calendarFolder.Items
strFind = "[AllDayEvent] = True And " & "[Start] = " & Quote(FormatDateTime(dateapp, vbShortDate) & " " & FormatDateTime(dateapp, vbShortTime)) & " and [Subject] = " & Quote(subjectapp)
'MsgBox strFind
Set objAppt1 = colCalendar.Find(strFind)
If Not objAppt1 Is Nothing Then 'if find the appointment that is changing delete it
objAppt1.Delete
End If 'if it does not find the appointment we dont have to worry because it is already gone
Set olappointment = Nothing
Set calendarFolder = Nothing
Set objApp1 = Nothing
End If
End Sub
Then, I close the debugger window and attempt the date change again and it brings me directly the code snippet below with the "Compile Error: Syntax Error" message:
Code:
Private Sub creacita()
Dim olappointment As Outlook.AppointmentItem
'Using object rather than MailItem, so that it
'can handle posts, meeting requests, etc as well
Dim olExp As Outlook.Explorer
Dim calendarFolder As Outlook.MAPIFolder
'Dim olApp As Outlook.Application
'Set olApp = Outlook.CreateObject("Outlook.Application")
If Not InitializeOutlook Or olApp Is Nothing Then
MsgBox "There was an error initializating outlook"
Else 'if it is not able to initalizate outlook it will not create the appointment
Set olExp = olApp.ActiveExplorer
Set calendar 'Set calendarFolder = olApp.GetNamespace("MAPI").GetDefaultFolder(9)
Set olappointment = calendarFolder.Items.Add("IPM.Appointment")
With olappointment
.Start = [bid date]
.AllDayEvent = True
.Subject = ProjectName & "---" & Estimator
.BusyStatus = olFree
.Save
End With
Set olappointment = Nothing
Set calendarFolder = Nothing
End If
End Sub
Any advice would be appreciated. Thanks!
Peace,
Aaron