On exit form opens report on specific record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need when closing a form to open a report on a specific record.
So, I have this code:

Private Sub Form_close()
DoCmd.OpenReport "Invoice", acViewPreview, , "[DocId] = """ & Me.[DocID]
& """", acNormal

End Sub

The problem is that it opens the report always on the first record, no
matter which DocId I have.

If I run the code without closing the form it works fine.
I guess that the Form_close() event runs the code after closing the form and
so Me.DocId is Null.

Is there any way for running the code before closing the form?
 
DocID looks numeric by its suffix.

Try

DoCmd.OpenReport "Invoice", acViewPreview, , "[DocId] = " & Me.[DocID]
, acNormal
 

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

Back
Top