Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close an unsaved report 1

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
I have a report that is completely created by code for printing purposes. When the print job is done the report is deleted from memory; the report is never saved. I need the VB code to test to see if the report is open. I tried the Report collection but because it is not a saved report it doesn't show up.

By default Access names a code-generated report Report1, Report2, Report3, etc.

Here is the code that I tried but does not see the report:

Dim rptObj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
For Each rptObj In dbs.AllReports
If rptObj.Name = "Report1" Then
DoCmd.DeleteObject acReport, "Report1"
Exit For
End If
Next rptObj

Any ideas?

Thank you.

Everything should be made as simple as possible, but not simpler
--Albert Einstein


 
Try this:

Dim IsLoaded
IsLoaded = (SysCmd(acSysCmdGetObjectState, acReport, &quot;Report1&quot;) <> 0)
MsgBox IsLoaded

Should return True if the Report is Open.

To close the Report:

DoCmd.Close acReport, &quot;Report1&quot;, acSaveNo

Regards

Bill
 
billpower;

That's it :)

Thank you (and here's a star)!

Everything should be made as simple as possible, but not simpler
--Albert Einstein


 
MrMajik: with regard to this post I have a question: you said you are creating a report entirely in code.
I am trying to do something similer but am having trouble setting the recordsource of this new report.
can you tell me how you did that?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top