473,566 Members | 2,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print report from subform

21 New Member
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 3896
PianoMan64
374 Recognized Expert Contributor
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 New Member
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_confli ct.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,564 Recognized Expert Moderator MVP
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(Can cel As Integer)}.
  3. Redesign the report every time in your code - not recommended.
Feb 26 '08 #4

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

Similar topics

1
2113
by: DD | last post by:
I have a mainform with a subform. The main form as a dropdown box "chooseDate", in the afterupdate event i requery the subform so all records with the same date are viewed. Now i only want to print the selected records of the selected month Can any one advise on the code to add to the print button i have tried this StrLinkCriteria =...
2
2080
by: vulcaned | last post by:
Hi All, I'm stuck, so....... In Access97 I have a form which has a subform(setup as a continous form), after a user selects several things on the form the subform gets requeryed and displays the content approperiate to the selections the user made. Now, the user wants to print the sub-form only. I've tried putting a print button on the...
1
3125
by: Randy | last post by:
I have tried the code to attach a button to a form and use the help information on coding, but I can't seem to get it to work. I have a main form called MAIN CLIENT INFO2 There is a subform called Client Contacts. I want to print the current record using the ID field in the Client Contacts subform in a report. I want to print to a report...
2
1900
by: ChadDiesel | last post by:
Everyone on this group has been a great deal of help. I have another question that I could use some help with. Once again, here is a picture of my form: http://www.chadworld.com/images/form.jpg I have a form with a shipment destination at the top. I then have a subform that I enter boxes for that shipment. I have several shipments...
2
3309
by: ChadDiesel | last post by:
Hello, I have a form and subform with their tables linked by a field called Load_ID. I have a button on my subform that prints just the items listed on that particular subform (looking at Load_ID). I'm using the following code: DoCmd.OpenReport "Load Sheet", acPreview, , "= " & "'" & Me.Parent.Form! & "'" This works fine, but now I...
8
4886
by: stemo76 | last post by:
I have created a report with subform/subreports. I can see all the data on the screen but when I try to print it to a printer or adobe distiller I get 'The Microsoft Jet Database engine could not find the obect ". Make sure the object exists and that you spell its name and path name correctly.'. Everything prints expect for the last...
2
4248
by: ghat12 | last post by:
Hi, I am trying to print a subform containing approx 50 columns in datasheet view. The printout cannot fit more than 8-10 columns. Does anyone know of any way to print all columns; i don't care if the printout spans multiple pages. FYI, the records displayed in the sub-form are dynamically obtained based on some ad-hoc querying in the...
8
1951
by: Christina123 | last post by:
Currently working with Microsoft Office 2000 and whatever version of Access came with that. I am developing a database to track the comings and goings of shared tools. Everything works splendidly except I have printing issues, primarily I have no idea what I am doing. I have a form that contains the date and the info of the person doing...
12
3518
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to print the report three times, but do not know how
0
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.