[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: High
  • Security: Public
  • Views: 17
  • Last Modified:

docmd.close does not close form

Hi
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
    Forms("frmPaciente").frmExameLista.Requery
    Call logMe("btn_sairNovoExame_Click", "start")
    DoCmd.Close
    Exit Sub
    
errorTrap:
    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?
/joao
0
João serras-pereira
Asked:
João serras-pereira
  • 3
  • 3
1 Solution
 
Gustav BrockCIOCommented:
You may need:

DoCmd.Close acForm, "NameOfFormToClose"

Open in new window

0
 
João serras-pereiraAuthor Commented:
The form is itself
will be OK?
0
 
Gustav BrockCIOCommented:
Yes. Currently you are closing the other form, so ...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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,,,
0
 
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

0
 
João serras-pereiraAuthor Commented:
thanks! its (almost) working
but I do really need to post another question... Now I can't add records!
0

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now