473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Printing a Report from the Current Record on a Sub-Form

112 100+
I am working with Access 2007. I am trying to print a report from the current record on a Subform. My form is comprised of a Main form with a sub-form and another sub-form with in the sub-form.
Main form = Renters Info
Subform = Rental Info
Subform = Dates for rental

I want to print off a report for one rental that lists the info for the rental with the renter information. I have created a button on the Rental subform to print the report. I have tried various codes that I have found on the internet to connect the current record to the report, however it does not work. I keep getting a pop-up box that asks me to “Enter Parameter Value” for the FuntionID. If I enter the right ID it works(wrong Id I get an error), but I don’t want to have to enter the ID as it should just print the current record without asking?
Here are the three codes I have been working with. All with the same result.
Expand|Select|Wrap|Line Numbers
  1. Dim strDocName As String
  2. Dim strWhere As String
  3.     strDocName = "Contract"
  4.     strWhere = "[FunctionID]=" & Me!FunctionID
  5.     DoCmd.OpenReport strDocName, acPreview, , strWhere
  6. End Sub
  7.  
  8. Dim strReportName As String
  9.    Dim strCriteria As String
  10.  
  11.    strReportName = "Contract"
  12.    strCriteria = "[FunctionID]=" & Me![FunctionID] & ""
  13.    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
  14.  
  15. End Sub
  16.  
  17. Dim Condition As String
  18.     Condition = "[FunctionID]=[Forms]![Main]![SubFunctionForm].[Form]![FunctionID])"
  19.     DoCmd.OpenReport "Contract", acViewPreview, , Condition
  20.  
  21. End Sub 
  22.  
I am not sure what I am doing wrong but think it is probably something to do with the printing for a subform? Any Ideas?

Thanks
Feb 13 '12 #1
5 6029
NeoPa
32,556 Expert Mod 16PB
You have two end subs with no start subs. End subs can possibly be omitted but the start subs are nearly always critical.
Feb 13 '12 #2
Redbeard
112 100+
To cleairify, these are the three different codes I have tryed and got the same result.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Contract_Click()
  2. Dim strWhere As String
  3.     strDocName = "Contract"
  4.     strWhere = "[FunctionID]=" & Me!FunctionID
  5.     DoCmd.OpenReport strDocName, acPreview, , strWhere
  6. End Sub
  7.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Contract_Click()
  2. Dim strReportName As String
  3. Dim strCriteria As String
  4.  
  5.     strReportName = "Contract"
  6.     strCriteria = "[FunctionID]=" & Me![FunctionID] & ""
  7.     DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
  8.  
  9. End Sub
  10.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Contract_Click()
  2. Dim Condition As String
  3.      Condition = "[FunctionID]=[Forms]![Main]![SubFunctionForm].[Form]![FunctionID])"
  4.      DoCmd.OpenReport "Contract", acViewPreview, , Condition
  5.  
  6. End Sub
Feb 13 '12 #3
NeoPa
32,556 Expert Mod 16PB
If the reporting of the error is correct then the problem is in your query. The field is probably mis-spelled as [FuntionID]. If that's not it then you need to be more careful with your posts as we can only work with what you post.

Certainly, without errors elsewhere, I would expect your first code example to work assuming the value of [FuntionID] is numeric.
Feb 13 '12 #4
Redbeard
112 100+
I found the problem... It was a bad link between my report and sub-report. Somehow it got linked directly to my table and not to the report itself. Thank for the suggestion of looking in the query, it let me back to the report where the error was.

Many Thanks NeoPa
Feb 13 '12 #5
NeoPa
32,556 Expert Mod 16PB
I think I may have helped accidentally then. Not that I wasn't trying to, of course. Just that the help was more of a by-product of the suggestion than the suggestion itself. Never mind. Any help is helpful at the end of the day ;-)
Feb 13 '12 #6

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

Similar topics

1
by: SAN CAZIANO | last post by:
I have to insert a button in the left of all record in a table to print the current record, simply create a table and print it in the printer. anyone have an idea or there is a printer/report...
4
by: John | last post by:
Hi Is there a way to print/e-mail the current record as it appears on a form? Thanks Regards
3
by: RWC | last post by:
Hello, I have an issue that's driving me batty! I have a report, whose record source is SQL based on a normalized set of tables. There are no nested queries and no dlookups in this record...
0
by: Spook | last post by:
I have written a query, that works and provides an output. But when I create a report to show this output in a "pretty" format. It comes up with the error "No Current Record". I used the Report...
3
by: ineedahelp | last post by:
I don't understand why I am getting the error message "No current record" at my code....Do While rs1!Symbol = rs2!Symbol....it seems that rs1 has values, but rs2 is empty. Any help? Many thanks!! ...
2
by: capdownlondon | last post by:
using ACCESS 2003 This code should do what I want, and it seems to, but every time i run it it says: No Current Record when i ctrl+break it the debug get hung up on the end sub. heres the...
3
by: Kalaine | last post by:
Access 2003: The following code is intended to delete the current record and all child records but results in an error, help please, thx. Private Sub CmdDelBSR_Click() On Error GoTo...
4
by: magmike | last post by:
I've created a report for the purpose of printing a one page summary of a record. Of course, when I created the report, it gives me a page on every record. Can I create a button to open that report...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
1
by: Shane van Heerden | last post by:
Hi, Hope you can assist... My table has two OLE/BLOB fields. 1 x OLE (Photo) and 1 x OLE (Signature). 1. With WebCam, I save my image - "Works Fine": Private Sub Capture_Click()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.