Error 5 in VB - Very Rare ... ???

I have a VB app I have loaded on at least 100 XP workstations.  It works without error probably 99.5% of the time.  It's a pretty simple message utility that uses an Oracle database.  It is a heavily used application (7x24) that stays active throughout each person's eight-hour shift.  About twice a month on assorted workstations, one or two users of this app will get an "Error 5 - Invalid Procedure Call or Argument" pop up.  It's not simultaneous; there doesn't seem to be any pattern.  They exit the app and restart, and all is well.  I have inserted an error handler to isolate the error, and it reports that the error occurs in "Housecleaning", a small section of code that handles some rather unspectacular tasks...


'Set Detail Error Message
    DetailError = "Housecleaning"

'Reset the display of both the groups and the people back to the top of the list, call
'WipeMessage to clear the entry box, set the Reciept Check to False, set Send to History
'to True, and set focus back to the entry box

    lstAllUserNames.TopIndex = 0
    lstAllGroups.TopIndex = 0
    chkReciept.Value = False
    chkHistory.Value = 1
    Call WipeMessage

'Re-enable the timer

    tmrSendMsg.Enabled = True

    Exit Sub


(This is the "Wipe Message" code which is called above):

Function WipeMessage()
    MousePointer = vbHourglass
   If ClearMsgAfterSend.Checked = True Then
      Text_Message.Text = vbNullString
   End If
    MousePointer = vbNormal
End Function


I cannot find any reason for an Error 5 message.  Do you see anything that could trigger an error?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Text_Message.SetFocus << will raise error 5 if it is not enabled.
Also (unrelated) the Mousepointer should be set to vbDefault.  vbNormal is used for windowstates.  I think they are both 0 however.
UPRRDevelopersAuthor Commented:
Thanks for the quick responses.  I read here about how setting focus to a disabled entity could cause that error.  The Text_Message box is set to enabled at startup, and I never, throughout the entire code, ever set it to enabled = False.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Could the error be bubbling up from tmrSendMsg_Timer() ?
Always add:




I think this is very unnessary error. We never need to know the result of a SetFoucs method.

UPRRDevelopersAuthor Commented:
Hmmmmm  ...   It is possible that I could have some weird loop in the code that causes a problem if a person has a certain screen condition when the timer goes off.  I'll have to check that out.
Simply  add

On Error Resume Next before the setfocus call

Remember control will inherit the visible property from its container.

UPRRDevelopersAuthor Commented:
Ajith, I can see why it's a good idea to set the Visible setting to True before doing a SetFocus, and I'll do that in the future.  I just searched the code, and at startup, the box is set Visible = True, and it is never set either way for the rest of the entire app.  

I guess what really bothers me is, this app is used to send messages to other people in our office hundreds of times a day, and thousands of times per month.  If this was something like a disabled or invisible box setting, I would think it would be happening much more.  I know 20-30 errors out of 10,000 is very low, but as a developer, it is driving me nutz!  Thanks for the help so far.
If SetFocus method fails it will raise error 5: invalid procedure call

Just add a check, I think this will solve the problem

If Text_Message.Visible Then Text_Message.SetFocus

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
UPRRDevelopersAuthor Commented:
Several good suggestions here.  I'll split the points and increase them overall because you guys were so quick and informative.
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
Visual Basic Classic

From novice to tech pro — start learning today.