João serras-pereira
asked on
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:
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
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes. Currently you are closing the other form, so ...
ASKER
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,,,
It might be the same issue - it is operating on the other form. Try:
If Me.Dirty = True Then
Me.Dirty = False
End If
ASKER
thanks! its (almost) working
but I do really need to post another question... Now I can't add records!
but I do really need to post another question... Now I can't add records!
ASKER
will be OK?