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

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
 
L

Linda Burnside

Specify the name of the form you want to close.

DoCmd.Close acForm, "Form1"

Linda
 
T

TC

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]
 
B

brback

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top