docmd.close does not close form

On my app I have a button aiming at opening an external form which collects some data, computes it, adds a record to the database and should return to the invoking form.
The new form is "modal" and "pop-up".

so I click the button, it opens the form, fills/computes data, and I have a "close button" (the form has no close event or button).

currently, the code  on the "close"  button is:

Private Sub btn_sairNovoExame_Click()

On Error GoTo errorTrap

    Call logMe("btn_sairNovoExame_Click", "start")
    If IsNull(Me.frm_MotivoExame) Then
        MsgBox "Motivo de Exame não preenchido"
    End If
    If IsNull(Me.frm_dataExame) Then
        MsgBox "Data de Exame não preenchida"
    End If
    Me.frm_idExame = Forms![_intData].frm_exameRecCount
    Forms![_intData].frm_exameSalvo = True
    DoCmd.RunCommand acCmdSaveRecord
    Call logMe("btn_sairNovoExame_Click", "start")
    Exit Sub
    MsgBox "[btn_sairNovoExame_Click]." & "[" & Err.Number & "].[" & Err.Description & "]"
    Call logMe("btn_sairNovoExame_Click", "errorTrap:" & "[btn_sairNovoExame_Click]." & "[" & Err.Number & "].[" & Err.Description & "]")
    Resume Next
End Sub

Open in new window

So I though that on the "Docmd.Close" it shouls close itself and control would be back to the invoking Form.

But what is happening is that (1) the form does not close, (2) the close event of the invoking form is fired and (3) the statement " DoCmd.RunCommand acCmdSaveRecord" crashes when invoking the second time

can anyone help?
João serras-pereiraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
You may need:

DoCmd.Close acForm, "NameOfFormToClose"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
João serras-pereiraAuthor Commented:
The form is itself
will be OK?
Gustav BrockCIOCommented:
Yes. Currently you are closing the other form, so ...
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

João serras-pereiraAuthor Commented:
Thanks! It's running. Now the save record part. i'll post a special question for it. I think that, because the form is bounded, I will not need to save the record. It'll do on its own,,,
Gustav BrockCIOCommented:
It might be the same issue - it is operating on the other form. Try:

If Me.Dirty = True Then
    Me.Dirty = False
End If

Open in new window

João serras-pereiraAuthor Commented:
thanks! its (almost) working
but I do really need to post another question... Now I can't add records!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.