469,599 Members | 2,700 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,599 developers. It's quick & easy.

Print report from subform

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
3 3499
PianoMan64
374 Expert 256MB
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
sconard
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
32,198 Expert Mod 16PB
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.

Similar topics

1 post views Thread by DD | last post: by
2 posts views Thread by vulcaned | last post: by
1 post views Thread by Randy | last post: by
2 posts views Thread by ChadDiesel | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.