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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making report from form with subform 1

Status
Not open for further replies.

bfamo

Technical User
Feb 16, 2006
132
NO
Hello world
I have a form called FrmCustomer (Which contains information about the customer) with a subform called FrmOrder(with information about the order).
What I want is a BtnReport_Click code that sends the current order from the form to the report I've made.

I have previously used this code in a form without a subform, but it obviously doesn't work when there is two forms involved.
Code:
DoCmd.OpenReport "RptInfoCustomer", acViewPreview, , "[CusID]=Forms![FrmInfoCustomer]![CusID]"

So, how do I get my report to show information from both the FrmCustomer and FrmOrder?

Any help here will be greatly appreciated!
 
Can you not just make a report that contains the same information as the forms, and then put a print button on the form?

Pampers [afro]
Keeping it simple can be complicated
 
I've tried that, but the report then shows the current record in the main form and all registered records in the subform.

You see, I want the report to show the current record in the main form and the current record in the subform.

Thanks ;)
 
you could set the link child/master property of the subreport... just like in the subform.

Pampers [afro]
Keeping it simple can be complicated
 
When I look at the child/master property it says "CusID" on both master and child. This has been set up by Access automatically. Is this how it should be?

I didn't think that this would be a big problem, but clearly it is... (not taking my IQ into consideration) ;)

Is it possible to modify the line of code that I first posted into something that also covers the subform?
 
That looks like the right child/master property...
You say:
You see, I want the report to show the current record in the main form and the current record in the subform
.
What do you mean by current record in the subform? Does it only show one record (thus being a single form)?

Pampers [afro]
Keeping it simple can be complicated
 
allright, lets see...

Lets say I get a telephone from a customer who wants to place an order. I start "FrmCustomer" to look him up. Once I've found him, I have all his information in "FrmCustomer" which is the main form.

To place the new order, I make a new record in "FrmOrder".
Once I have filled out the order, I want a button like "Order confirmation" to send the information to my report. The report contains fields from both the subform and the main form, such as Company name, adress, date, Item1, Item2 etc.

example.jpg
 
Ok, that is clear. You have a main form with a non continous (single) subform.

To actually print the right report, you have to select the right record (=orderID), which is linked to the customer through CustomerID. You don't have to create a report with a subreport for that (base your report on a query where the two tables are joined). Then on your main form create a button that executes something like:
Code:
DoCmd.OpenReport "RptInfoCustomer", acViewPreview, , "[OrderID]=Forms![FrmInfoCustomer]![frmInfoOrder].Form![OrderID]"

Or put a button on the subform with something like:
Code:
DoCmd.OpenReport "RptInfoCustomer", acViewPreview, , "[OrderID]=Me.OrderID"




Pampers [afro]
Keeping it simple can be complicated
 
Brilliant!!

Looks like it's working fine now!
Thanks alot for staying with me on this one ;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top