Click to See Complete Forum and Search --> : HELP! Run-Time Error '2144717851(80010105)'


Bonovox011
June 25th, 2001, 12:37 PM
My VB program is used to manage contacts in stored in a public folder. The error only occurs the first time the program is run after a login. It happens when trying to create a contact on the .move event of a ContactItem. Here is some code, hopefully you can help me out!

thanks in advance,

Bonovox011

Private Sub cmdCreate_Click()

On Err GoTo errorHandler

'Create an instance of Outlook
Set objApp = New Outlook.Application

'Create a namespace within Outlook so that I can access folders
Set objNameSpace = objApp.GetNamespace("MAPI")

'Make objContact a Conact Item in this instance of Outlook
Set objContact = _
objApp.CreateItem(olContactItem)

'set the folder to a public folder "VF Contacts"
Set objFolder = objNameSpace.Folders("Public Folders").Folders("All Public Folders").Folders("TIAS Public Folders").Folders("North America").Folders("United States").Folders("STR - Strathroy").Folders("VF Administration").Folders("VF Contacts")

'Attribute all the fields of the form to a spot in the contact form
With objContact

.CompanyName = txtComName.Text
.BusinessAddressStreet = txtBusStreet.Text
.BusinessAddressCity = txtBusCity.Text
.BusinessAddressState = txtBusState.Text
.BusinessAddressCountry = txtBusCountry.Text
.BusinessAddressPostalCode = txtBusPC.Text
.BusinessTelephoneNumber = txtBusPhone.Text
.OtherFaxNumber = txtBusFax.Text
.FirstName = txtConFName.Text
.LastName = txtConLName.Text
.MobileTelephoneNumber = txtEmail.Text
.Home2TelephoneNumber = txtWSIB.Text
.HomeTelephoneNumber = txtInsurLiab.Text
.TelexNumber = txtAttachS.Text
.Department = txtAttachE.Text

'Save the changes made
.Save

'Move them to the public folder
.Move objFolder

End With


'Reset the Instance of Outlook to nothing
Set objContact = Nothing
Set objApp = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing

'Display that Contact was created
intQValu = MsgBox("Contact Created!", , "Vari-Form")

'Ask User to Add another Contact or to continue
intQValu = MsgBox("Create Another Contact?", _
vbYesNo + vbQuestion, "Response Required")

'if user press yes
If intQValu = vbYes Then

'call main form load to start program over again
txtComName.SetFocus
Call Form_Load

Else

'Display main menu
Unload frmCreate
frmMainMenu.Visible = True
'Reset the Instance of Outlook to nothing
Set objApp = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing
Set objContact = Nothing

Exit Sub

End If

'Reset the Instance of Outlook to nothing
Set objApp = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing
Set objContact = Nothing

'exit sub to avoid error handler from running if everything is ok till here
Exit Sub

'error handler for any errors that occur
errorHandler:

'return a messsage box with error number and description
intQValu = MsgBox(Err.Number & " " & Err.Description, , "Vari-Form")
Err.Clear

'set variables to nothing
Set objApp = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing
Set objContact = Nothing

Call Form_Load

Resume Next


End Sub

Bonovox011
June 25th, 2001, 04:53 PM
I can't figure out why it won't run the first time some logs in but as soon as you end the program and start again it works perfectly fine, I'm getting desperate.

Thanks again,

Bonovox011