Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print only the current record to a report 2

Status
Not open for further replies.

RyDan46

MIS
Mar 28, 2005
24
GB
i have a subforum in my forum and i need to print it in a report. But the subforum will be holding many more pages for the same person, but i only want to print off the current record which is showing to the report how do i do this ?

many thanks

RyDan
 
thanks for the reply
Ive already looked at the link but i dont really understand it (sorry for been thick ;0)

Im sure its what i need but Can u explain it to me in
god i sound like such a NOOB

RyDan
 
Tell me the what are the field on the mainform and the subform. Also how the subform and the mainform connected? (Master/child relation).Tell me the field names in both tables.


________________________________________
Zameer Abdulla
Visit Me
Hold your child's hand every chance you get.
A time will come when he or she won't let you.
 
If you are using VBA do the following

Code:
Private Sub cmdpreviewcurrent_Click()
strwhere = "[RECORDID] = " & Me.[RECORDID]
strReportName = "name of the report"
DoCmd.OpenReport strReportName, acViewPreview, , strwhere
End Sub

where RECORDID is the unique key field of the record.
Put this in the 'on click' property of the command button which you use to open the report.




Program Error
Programmers do it one finger at a time!
 
sorry for the delay, with the weekend and all that

My fields on the main forum are

contact id
title
first name
last name
address 1 and 2
town and postcode
phone number and mobile
car make model
registation

Subforum

service ID
first name
last name
registation
description
parts replaced
Total

i have linked the forum to the subforum through first and last name and registaion

hope this helps u sort out my problem
 
When you are saying current record, I assume it is the current record in the subform.
You need to create a report with all the required fields from the subtable(Service record). Create a button on the subform and place the code
Code:
Private Sub cmdPreviewReport_Click()
    strwhere = "[service id] = " & Me.[service id]
    strReportName = "Report Name"
    DoCmd.OpenReport strReportName, acViewPreview, , strwhere
End Sub
I have altered PrgramError's sample code

Some notes to you.
[ul]
[li] Try to avoid spaces in the field names. Use something like FirstName or first_name [/li]
[li] While you have all informations of the customer in the main table you don't need to store that in the sub table. connect them with Registration Number or Customer ID. You can then use a query to retrieve data from both the tables [/li]
[li] Also need to split the sub table into two (Service & Parts used ) connect them with ServiceID.[/li]
[li] Read more about Fundamentals of Relational Database system[/li]
[li]Read more about LESZYNSKI (HUNGARIAN) NAMING CONVENTION[/li]
[/ul]
Hope this helps

________________________________________
Zameer Abdulla
Visit Me
The best thing to spend on your child is your time.
 
thanks for the post back
i'll go and work at it now and let u no what happens

thanks for the advice

RyDAn
 
Great It worked
BUT When i go onto the report the info which i want to print is there ( good), but when i want to do another report for a customer the old info is still on the report how do i clear it so that the report is clear of any other customers info ?
 
Are you sure you are talking about report? There can't be any "old info". All information available there are brought from the underlying query / table.
Are you sure you created the command button on the subform not on the main form? It should be on the subform.
Code:
strwhere = "[service id] = " & [b][COLOR=red]Me.[/color][/b][service id]
here Me.is the current form.

________________________________________
Zameer Abdulla
Visit Me
The best thing to spend on your child is your time.
 
yeah im sure that the command button is on the subfourm
any ideas

The info is stored into the service record TABLE
and i think thats why its keeping the old data on the RECORD

I need a clear button or something like that

any ideas
 
BUT When i go onto the report the info which i want to print is there ( good), but when i want to do another report for a customer the old info is still on the report how do i clear it so that the report is clear of any other customers info ?

Are you getting reports and forms mixed up do you mean subform by this statement.

Program Error
Programmers do it one finger at a time!
 
No im not getting mixed up
When i click my report button it adds the info off the current subfourm (showing) onto the report but if i go to another customer and decide to do another report it adds the info but it has the old info still on it from the last time

I need it to be clear so i can print the info off seperatly

Does that clear the confusion up.
any ideas thanks in advance
RyDan
 
Just to hopefully add to the information about printing a current record, I thought I would post a few things I discovered. I had a form that had a subform on it and the data was based on a query. I wanted to print current records only with a report that is based on this query's data. I used the code ZmrAbdulla suggested in a button's On Click Event Procedure but I could not get it to work. What I had to do was make sure my ClientsID was included in the query even though it is not printed in the report.
That is the ClientsID referred to in:
strwhere = "[ClientsID] = " & Me.[ClientsID]
Also I did not have to put the button on the subform as some have suggested. I hope this helps, as I always have to look at this anew when I need to do this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top