Outlook 2010 VBA Object required Error

This is my first question here so bear with me. I have an Outlook/VBA issue that is driving me batty.
I have customized the Outlook Contact form and added a number of user defined fields and now I need to run a VBA routine to update 2 newly added custom fields.
Here's the relevant code:
    Set objExpl = Application.ActiveExplorer
    If Not objExpl Is Nothing Then
        Set objSelection = objExpl.Selection
        If objSelection.Count > 0 Then
            For i = 1 To objSelection.Count
                Set objItem = objSelection.item(i)
                If Not objItem Is Nothing Then
                    If objItem.Class = olContact Then
                        objItem.UserProperties("EmployerIndustry").Value = txtIndustry.Text

The user defined field "EmployerIndustry" gets the value from the textbox. When this line is executed, a message box is thrown up: Script Error Object required: '' Line No:74
And when I check the error number it shows nbr 91.

However, if I change the user defined property to another one, say "Newsletter" there's no error. Yesterday I called this property "MajorCategory" and it kept throwing this error, so I changed the field name to "EmployerIndustry" and then it worked. Today the same error is showing up again.

After the messagebox is dismissed the code functions as it should and the value gets set in the user defined field. If I add a Quickwatch and check the values, everything looks as it should.

If I open a contact item and check User-defined fields in this item and in this folder, the field is there.

I have other VBA routines that do various updates to User-defined properties and they all run without errors with the same code. I have seen some people suggest that I declare and initialize the UserProperties collection and then add the property and assign that to a variable and finally set the value from the text box to this variable, tried that, same result.

Can you shed some light on this? Would really, really appreciate it.

Leif BorgmanIT Support/WebMasterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leif BorgmanIT Support/WebMasterAuthor Commented:
I figured out a workaround for this problem. Do not know what was causing it, but the field that was giving the Object Required error was bound to a combobox on the contact form. After I changed that to a bound textbox instead, and used an unbound combobox for the selection of the property, it runs without throwing up the error.

Strange indeed, but it works.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Seth SimmonsSr. Systems AdministratorCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Leif Borgman (https:#a42446054)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.