Yes/no msgbox closing the wrong form at times....

Yes/no msgbox closing the wrong form at times....

Post by brbac » Fri, 13 Jan 2006 00:24:48


hi, i made a "form1" with a yes/no exit msgbox with this as a code:

Private Sub command53_Click()
Dim command53 As Integer
If Income = 0 Then
command53 = MsgBox("mymsg", vbYesNo, "headline")
Else: DoCmd.Close
End If
If command53 = vbNo Then
DoCmd.Close
End If
End Sub

This works perfectly fine when i only have "form1" open, but when i open
"form1" from another form
which is called "menu", then the msgbox command closes the form "menu" first,
then "form1"

Could anyone help me to specify what form the code should choose to close ?
Thanks alot in advance
 
 
 

Yes/no msgbox closing the wrong form at times....

Post by Linda Burn » Fri, 13 Jan 2006 00:30:45

Specify the name of the form you want to close.

DoCmd.Close acForm, "Form1"

Linda

 
 
 

Yes/no msgbox closing the wrong form at times....

Post by TC » Fri, 13 Jan 2006 00:31:28

Try: docmd.close acform, me.name

Note: you must indent your code, to make it readable. Get in the habit
of doing this always.

if this then
blah blah
if whatever then
blah blah
blah blah
endif
else
blah blah
bah blah
endif
etc.

HTH,
TC [,MVP Access]
 
 
 

Yes/no msgbox closing the wrong form at times....

Post by brbac » Fri, 13 Jan 2006 00:43:40


habit
of doing this always.

Will do, thanks alot to both for fast respond