Solved

SetFocus error with VB6 and XP

Posted on 2002-04-27
12
4,226 Views
Last Modified: 2008-02-20
I have a form with a TextBox named "txtDateFin".  When KeyPress = Enter (13), the focus go to the ComboBox named "cmbRapport".  In Windows 2000, it's ok.  In Windows XP, i receive intermittent error "Error 5 Invalid procedure call or argument" on line : cmbRapport.SetFocus

Thanks

This my function:

Private Sub txtDateFin_KeyPress(KeyAscii As Integer)
   
    If KeyAscii = 13 Then
        KeyAscii = 0
        If txtDateFin.Text = "" Then
            cmdDateFin.SetFocus
        Else
            If IsDate(txtDateFin.Text) = False Then
                pnlNonTher.Panels(1).Text = "Date error"
                Exit Sub
            Else
                lblRapport.Enabled = True
                cmbRapport.Enabled = True
'???????????????
                cmbRapport.SetFocus '??? Error 5 procedure call or argument
'???????????????
            End If
        End If
    End If
End Sub
0
Comment
Question by:andreouellet
12 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 6973041
>                cmbRapport.Enabled = True
>'???????????????
>                cmbRapport.SetFocus

try:
                  cmbRapport.Enabled = True
                  cmbRapport.Refresh
                  cmbRapport.SetFocus
0
 

Author Comment

by:andreouellet
ID: 6973050
The cmbRapport.Refresh not working.
I add too cmbRapport.Visible = true.
The cmbRapport.Visible not working too.
0
 
LVL 15

Expert Comment

by:ameba
ID: 6973054
Does any of these return False:
    MsgBox cmbRapport.Enabled, , "Enabled"
    MsgBox cmbRapport.Visible, , "Visible"
0
 

Author Comment

by:andreouellet
ID: 6973071
MsgBox cmbRapport.Enabled, , "Enabled" >> true
MsgBox cmbRapport.Visible, , "Visible" >> true

---------------------------------------------------------
I add the line : "if cmbRapport.Enabled = True then" but problem stay.  But with the line "DoEvents" before the line "cmbRapport.SetFocus" the problem disappear?????
---------------------------------------------------------

     lblRapport.Enabled = True
     cmbRapport.Enabled = True

     if cmbRapport.Enabled = True then 'problem stay
          DoEvents 'Problem disappear ???
'???????????????
          cmbRapport.SetFocus '??? Error 5 procedure call or argument
     end if
'???????????????
0
 
LVL 15

Accepted Solution

by:
ameba earned 200 total points
ID: 6973090
>          DoEvents 'Problem disappear ???

DoEvents allows execution of low prority tasks.

I thought cmbRapport did not finish redrawing its enabled state, when I suggested "cmbRapport.Refresh"
But it looks like there are some other tasks (maybe redrawing container of cmbRapport?)

You can delete the question, if DoEvents works for you.
0
 

Author Comment

by:andreouellet
ID: 6973101
Thanks for your help, ameda
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:ameba
ID: 6973106
Better "thank you" would be if you deleted the question.  I don't like B grade.
0
 

Author Comment

by:andreouellet
ID: 6973173
To ameda:

Why do you say "I don't like B grade"?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6974371
andreouellet,

ameba complains about any non-A grade.  I think it's petty and not good for user-relations.  In this case, it appears that ameba helped you arrive at some resolution, which (by ExEx grading rules) deserves a B grade.

If you are confused or upset about ameba's comment, I suggest you report your displeasure in the ExEx community support area.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6975260
aikimark,

I'll try to be polite about this, but... I don't know what your issue with ameba is, but I do know that it's not your concern. If ameba has a problem with a grade, he can leave a question in CS for the Moderators, and we'll adjudicate it. If you're ever a Moderator, then it's your place, but in the meantime, please let us do our jobs.

andreouellet,

Grading at EE is a touchy subject. It helps if you think of it like the "10-Point Must" system in boxing. You should assume an A, and then deduct depending on how much use you get from the responses. If the response leads you to the correct information, then a B might be justified, depending on how much additional work you have to do. You should almost never leave a C, but rather, give the Experts the chance to give you more information.

ameba,

This question will NOT be deleted. I have no problem with your asking andreouellet why SPECIFICALLY he gave you a B and what you have to do to make it an A, but a B is a perfectly legitimate grade and the fact that you "don't like it" is not reason enough for upgrading it.

Netminder
CS Moderator
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6975264
The goal on grading is to assess the value given in the question, and to give it the level of quality that will entice others to visit the solution if it served you once the question has migrated to our PAQ.  People are more likely to visit a question in our PAQ that is an A level response than one which is a B level response.

Hope that helps add insight.  In addition, the points you give a question remain the same, but the points which flow to the expert are a direct result of the grade assigned.

Example:  100 points at an A grade = 400, B = 300, C=200

Moondancer - EE Moderator
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6987759
Based on review and feedback from other moderators, the grade is changed.

Please see below.

Computer101
E-E Moderator



How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades.
If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade,
since they have taken the time to provide you with a working solution. If a possible solution is incomplete
- ask for clarification or details before accepting the answer and grading it. People should not be
given lower grades because of incorrect grammar or because you just accepted their answer or comment
to close the question. Keep in mind, your question and any follow-up comments should be focused so that
there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information
that thoroughly answered your question. An "A" can also be given to any answer that you found informative
or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were
able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the
opportunity to clarify if you have questions about their solutions. If you have given the Expert(s)
ample time to respond to your clarification posts and you have responded to each of their posts providing
requested information; or if the answers, after clarification, lack finality or do not completely address
the issue presented, then a "C" grade is an option. You also have the option here of just asking Community
Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question.
Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now