Closing a form when a report opens

T

Tony Williams

I have a prompt form that the user selects which records to run a report on.
When the report opens I want the form to close. I've used this simple code
but it doesn't work. Anyone help?
Private Sub Report_Open(Cancel As Integer)

DoCmd.Close acForm, Me.Name

End Sub

Thanks
Tony
 
D

Douglas J. Steele

Me refers to the currently active object. Since that code is in the report's
Open event, "Me.Name" refers to the name of the report. You'll have to
replace that with the actual name of the form:

DoCmd.Close acForm "MyFormName"
 
T

Tony Williams

I've used this Doug
Domcmd.Close acForm frmviewid
and i get an error message

Runtime error 2493
This action requires an Object name argument

What have I done wrong?
Thanks
Tony
 

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

Top