Child forms & focus

I use child forms to show dbgrids and when I want to add new records to the database I show a form with modal 1; when in that form I have to show an error I use msgbox and that's the problem; when I close the msgbox the focus goes to the modal form, but when I close that form the focus goes to another application and my application is minimized instead of going to the child form. How can I change that and get the focus in the child form but without loosing the focus my application. I'm ussing VB5. Thanks.
Who is Participating?
DalinConnect With a Mentor Commented:
This is a Microsoft bug.
Check out:
BUG: Focus Does Not Return to an MDI parent form
There is the explanation and a resolution.
When you show the child form try the following

frmChild.Show vbModal, Me

Where ME is the parent form

Do you have code that minimizes the parent form ?
gironaAuthor Commented:
I've tried raygibbins solution and it doesn't work. I obtain an error about I can't show a child in modal way.
I don't have any code to minimize the main form, it minimizes itself when I show a msgbox and close the modal form.

Sorry did not realise it was an MDI application

Try setting the WindowState property of all MDIchild forms to
2 - Maximized , in the properties window.
Or set them in code to vbMaximized
When you show an MDIChild window, then all other MDIChild forms take on the same WindowsState as the Active MDIChild

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.