Closing a form using a command

  • Thread starter Thread starter Inma
  • Start date Start date
I

Inma

Hi,
I would like to close a form once the report is opened.
I used:
DoCmd.OpenReport "TEST", acViewPreview
DoCmd.Close acForm, Forms(0).frmTEST
But is not working.
What's wrong with it?
TIA
Inma
 
The close action requires the name of the form, not a reference to it. Try:
DoCmd.Close acForm, "frmTEST"
or -- if you are closing the form containing the code -- try:
DoCmd.Close acForm, Me.Name
 
Thank you Allen.
I used the code: DoCmd.Close acForm, Me.Name

to close a dialog form. But when I close the report and when I recall the
dialog form via a command, the form has the priory written data into it. I
thought closing the form would clear the old data.

Inma
 
To prevent it being saved, cancel the form's BeforeUpdate event, and undo
the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = True
Me.Undo
End Sub
 
Back
Top