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

  • Thread starter Thread starter brback
  • Start date Start date
B

brback

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
 
Specify the name of the form you want to close.

DoCmd.Close acForm, "Form1"

Linda
 
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]
 
TC wrote: Note: you must indent your code, to make it readable. Get in the
habit
of doing this always.

Will do, thanks alot to both for fast respond
 
Back
Top