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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close report which will not work!

Status
Not open for further replies.

lostmule

IS-IT--Management
Aug 2, 2007
3
CA
Good morning all,

I am attempting to modify the output (filename) by changing the .caption of a report. I have found something interesting, if I do not touch the 'caption' of the report, I can print other reports using the same 'template-report' no problemo. When I use the Report_MyReport.caption = "this is it", the report remains open but can not be closed unless I open manually the report then close it... I have attempted the docmd close report with no success.. here is what I have written:

'Here I am changing the value of the caption of the report
Report_NSCRequestFormRPT.Caption = SN.Value

'I am opening the report to debug this problem (not necessary)
DoCmd.OpenReport stDocName, acViewPreview

'Here I am preparing an email to send that report with a changed filename (using caption field it does just that)
DoCmd.SendObject acSendReport, stDocName, acFormatSNP, nscemail.Value, , , "Subject Line", "Email Text"

'Here it should close it.. but no joy (IF I do not modify the caption, it will close it)
DoCmd.Close acReport, "NSCRequestFormRPT"

Suggestion?

Merci!
 
I see three different names for the report in question...I would think this is the trouble.

You first line calls the report "Report_NSCRequestFormRPT"
You second and third line calls it "stDocName" - which is a defined variable most likely.
Your last line calls it "NSCRequestFormRPT"

I would recommend you replace the last line of your examples to use the stDocName. If that is a defined variable, all should work.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top