main form is shown undeliberately

I have a VB form that calls a procedure from
another class to verify whether an input in
a textbox of that form is in the allowed range
of input values. Now if the focus is lost in that
textbox the Lost event handling procedure in the
form calls this other procedure from the mentioned
class. This procedure in turn calls MsgBox when the
input value range is violated  to inform the user.
However, before this message box comes up the main
form is shown and over this appears the message box.
When OK is clicked the main form disappears again.
Is there a way to suppress the main form showing up
each time the MsgBox is shown? It does not make any
sense to have the main form shown in this occasion.
quark031698Asked:
Who is Participating?

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

x
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.

DalinCommented:
Quark,
There are problems related to use the LostFocus to validate input, and have a messageBox in the lost Focus event. Check out:
    PRB: GotFocus Event Fails If MsgBox Invoked in LostFocus Event          http://support.microsoft.com/support/kb/articles/q85/8/56.asp

             Validating Text Box Data Causes Extra LostFocus Events    http://support.microsoft.com/support/kb/articles/q96/8/46.asp
For some work around.

If you have further questions or problems, let me know.

Regards
Dalin
0
DalinCommented:
Quarek,
  What do you do after the message Box? Is your text box in the main form? Post/email me the code in the textbox lost_focus and the procedures your are calling if you still have problem. My E-mail: Dalin_N@MAilExcite.com.
Regards
Dalin
0
quark031698Author Commented:
I simply need to know how I can suppress the main
(startup) form coming up unvoluntarily

- the text box is not in the main form,
  is has its own form
- after the message box the control is given back
  to the form where the text box is located
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

clifABBCommented:
Is the form that has the textbox an MDIChild of the main form?
0
DalinCommented:
Quark,
If you do not need the main form, Try to put the code in the Lost_focus event, add frmMain.Visible =False or Set frmMAin=Nothing (If you dont need it) before you validate the data.

The main form will come out if you refers to something in the process. In the procedure you are calling, do you use anthing from the main form at all? Was the main form in the background or is it unloaded? Can you post the code inthe lost_focus event and the procedure it Calls?

Let me know if more problems.
Regards
Dalin




0
quark031698Author Commented:
It is not. I also tried to switch the main (startup) form
into an MDIform (and set accordingly the form with the textbox
to being an MDIChild of it) but the result was a different look-and-feel.
However, the problem disappeared, the main form kept staying
in the background as it should. The problem is I cannot accept
the different look-and-feel of the MDIform. Thus I need a
solution without using MDIforms.

0
clifABBCommented:
I'm sorry, I wasn't suggesting you use MDI forms, but had you been doing so, this might have been your problem.

In the main form's load event, do you have code that amounts to:
frmMain.Show
or
frmMain.Visible = True
?

When you refer to a control on a form, it causes that form to load (firing the Load event) if it's not already loaded.
0
DalinCommented:
I believe you have somewhere refers to something in the mainform, and triggler the mainform to show. That does not explain the aotumaticaly disappear, through.  If you still have the problem, after set visible to false, I can look at your code if you like. My e-mail: Dalin_N@MailExcite.com
Using LostFocus with MsgBox is tricky, through. It can cause enexpected results.
Regards
0
quark031698Author Commented:
To set the visibility to false within the *_LostFocus procedure
is a solution. However, it does not match the SW architecture
I have in mind. In this architecture the behaviour of a form
should be determined by that form itself, not by others changing
it. I need a solution with the main form setting itself to the
behaviour of always staying in the background.

Thanks for your attention so far!

Regards,

Wolfgang
0
DalinCommented:
Quark,

Put a break on the 1st line of code in the *_lostFocus sub, and then excute line by line by pressing F8. You should be able to see when the mainform comes up. Let me know the results.

Regards
Dalin

0
deightonprogCommented:
I would recommend setting a breakpoint in your lost focus event.  Step through the code from this point.  At some point int the main form initialise or load event you must be doing something to diasplay the form. e.g. Me.show for example
Have you considered putting the validation function in a BAS module, this is also more efficient.
0

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
DalinCommented:
deighton,
Isn't that what I already suggested?
0
deightonprogCommented:
Dalin - yes sorry it is, but your comment wasn't there when I started investigating the problem - your comment came just 15 mins before mine.  You could have made your comment into an answer!


0
DalinCommented:
deighton,
I see. However, this is not the soltion to the problem, it is just a way to search for the problem, that why I did not provide it as the answer.
Regards
Dalin
0
quark031698Author Commented:
I leave as it is. The problem is now being investigated
by some other people in my department.
But thanks anyway.

Best,

Wolfgang
0
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.