Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-25
10
Medium Priority
?
202 Views
Last Modified: 2010-05-02
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
   
    Text_Message.SetFocus
    MousePointer = vbNormal
   
End Function

==================================================================

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



0
Comment
Question by:UPRRDevelopers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 12404004
Text_Message.SetFocus << will raise error 5 if it is not enabled.
0
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 800 total points
ID: 12404048
Also (unrelated) the Mousepointer should be set to vbDefault.  vbNormal is used for windowstates.  I think they are both 0 however.
0
 

Author Comment

by:UPRRDevelopers
ID: 12404112
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 800 total points
ID: 12404216
Could the error be bubbling up from tmrSendMsg_Timer() ?
0
 
LVL 4

Assisted Solution

by:AjithJose
AjithJose earned 1200 total points
ID: 12404345
Always add:

Text_Message.Visible=True

before

Text_Message.SetFocus




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

~Ajith
0
 

Author Comment

by:UPRRDevelopers
ID: 12404380
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.
0
 
LVL 4

Assisted Solution

by:AjithJose
AjithJose earned 1200 total points
ID: 12404445
Simply  add

On Error Resume Next before the setfocus call

Remember control will inherit the visible property from its container.

~Ajith
0
 

Author Comment

by:UPRRDevelopers
ID: 12404497
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.
0
 
LVL 4

Accepted Solution

by:
AjithJose earned 1200 total points
ID: 12404575
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

0
 

Author Comment

by:UPRRDevelopers
ID: 12404874
Several good suggestions here.  I'll split the points and increase them overall because you guys were so quick and informative.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question