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

Print report from subform

P: 21
I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a report or generate a report from recordset that created the datasheet view. I do not see the ability to create a report from a form. How is this best achieved?

Thank You
Feb 25 '08 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 374
Print report from subform
--------------------------------------------------------------------------------

I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a report or generate a report from recordset that created the datasheet view. I do not see the ability to create a report from a form. How is this best achieved?

Thank You
The way that you would have to do it is, since you've created a form that has the VBA based query in it, you would have to do the same for the report. You would get into the Report_Open() and define your VBA Query there. This way you can print a report based on that same information. You won't be able to use any of the wizards at all since your datasource is going to be Code based.

You will have to layout all your fields the way that you want them to appear on the report.

If you want more specific answer to this question, please post your code, and I can help you write what you need to do.

Thanks,

Joe P.

P.S. You can send me a message if you want details.
Feb 26 '08 #2

P: 21
Say I have a report named r_conflict built with same fields as vba sql string query. Would it not be possible to set a button on the subform and use the same query code to open a report?
My attempt give me an error "You cant set the record source property in print preview or after printing has started"

strSql = very complex sql string

Code:___________

Report_r_conflict.RecordSource = strSql

__________________

How do I open the report?

The way that you would have to do it is, since you've created a form that has the VBA based query in it, you would have to do the same for the report. You would get into the Report_Open() and define your VBA Query there. This way you can print a report based on that same information. You won't be able to use any of the wizards at all since your datasource is going to be Code based.

You will have to layout all your fields the way that you want them to appear on the report.

If you want more specific answer to this question, please post your code, and I can help you write what you need to do.

Thanks,

Joe P.

P.S. You can send me a message if you want details.
Feb 26 '08 #3

NeoPa
Expert Mod 15k+
P: 31,769
Your options are :
  1. Pass the report a Filter parameter when opening it.
  2. Change the RecordSource property within the Open event procedure {Sub Report_Open(Cancel As Integer)}.
  3. Redesign the report every time in your code - not recommended.
Feb 26 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.