Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox function and non-modal form

Status
Not open for further replies.

newora

Programmer
Aug 19, 2003
133
GB
Some more help please - I seem to be in complete brain dead mode today!!

I have solved one issue thanks to you guys, but another has now raised it's head.

The main form in my appliaction displays another form non modally, so that it can be minimised and other application features used.

However on this form that is displayed non-modally, if I display an error message, using msgbox, then the non-modal form disappears and the main appliaction form is shown, with the msgbox on it!!

It is obviously something to do with the form being displayed non-modally, as if I display it modally it works ok, except that I can not minimise the window and use other aplication functionality.

Should I not use msgbox and implement a function of my own to do a similiar thing? (must be one around here somewhere I am sure).

Thanks again for your help.
 
If the msgbox function is in the main form then the main form will and must appear, and the modal output box (messagebox) will appear. To display messages the way you want, you could create a form; frmError with labels etc.. and use it as msgbox.


Hope this helps
 
Well that's the thing, the msgbox function is in the form that is displayed non-modally, it is not in the main application form.

Maybe the fact that I have a sub main and I am displaying the main application form non-modally, is having an effect. I have a login form that is displayed first.

The problme is that if I display the main application form modally, it will not let me display the other form non-modally.

I am so confused!!
 
>It is obviously something to do with the form being displayed non-modally
I wouldn't draw that conclusion. The only thing you can conclude is that what it in fact has to do with is overridden if you show the form modally.

I put together some forms as you have them here:
Code:
'in a module
Sub main()
Form1.Show
End Sub

'in form1
Public Sub DoMsgBox()
MsgBox "Test"
End Sub

Private Sub Command1_Click()
Form2.Show
End Sub

'in form2
Private Sub Command1_Click()
Form1.DoMsgBox
End Sub

This all works just fine, which suggests that the problem does not lie in the non-modality of the forms. If you want to provide more context, maybe someone can see what's wrong.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top