By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,304 Members | 1,739 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,304 IT Pros & Developers. It's quick & easy.

open report in a succession

P: n/a
In order to check for figures i want to make a function that opens and
closes a report in a succcession depending on the option values
chosen.Instead of clicking on the option group called Houses, i use the
value of the field :
Dim stDocName As String
stDocName = "RptHouseReport"

Me!Houses.Value = 1
DoCmd.OpenReport stDocName, acPreview
DoCmd.Close acReport, "RptHouseReport"
Me!Houses.Value = 1
DoCmd.OpenReport stDocName, acPreview
DoCmd.Close acReport, "RptHouseReport"

Me!Houses.Value = 3
DoCmd.OpenReport stDocName, acPreview
DoCmd.Close acReport, "RptHouseReport"
etc... etc....

However my function stops at the first report,, it opens the report for
the first option and then stops, it stays wih the report opened.What is
the reason for my wrong function ?

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> In order to check for figures i want to make a function that opens and
closes a report in a succcession depending on the option values
chosen.Instead of clicking on the option group called Houses, i use the ....... However my function stops at the first report,, it opens the report for
the first option and then stops, it stays wih the report opened.What is
the reason for my wrong function ?
You should ask first if this is what you really want. If your code says:
DoCmd.OpenReport stDocName, acPreview
DoCmd.Close acReport, "RptHouseReport"


then what are you gaining if it opens and closes immediately? The idea of
preview mode is for you to be able to look at it, or print it, or take
another action. So if your code *did* execute as you intended, then you
would have no chance to really view the report

Take out the DoCmd.Close. When your user closes the report by clicking on
the 'X', it will close.

BTW, I would recommend having error-handling in every function that opens a
report.

--
Darryl Kerkeslager
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.