Programming reports

  • Thread starter Thread starter HSalim
  • Start date Start date
H

HSalim

Hi All:
it has been so long since I programmed reports and I have forgotten
everything or everything has changed.
Here are two tasks that I am struggling with.
Report is based off a query. qrySalesHeader
Report has subReport baed on qrySalesItems.

ON main report, I have a textbox - txtBillAddress:
ControlSource: =ConcatAddress(BillAddr1, BillAddr2, BillAddr3)
BillAddr1,2,3 are columns in qrySalesHeader; ConcatAddress is a function
that nicely formats the three address lines and removes unneeded spaces.
Similarly I have a textbox - txtShipAddress.

Question:
1. Instead of binding txtBillAddress to the three columns, I wanted to leave
it unbound and set the value at run time, say in the
GroupHeader Formatevent

For example
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
Me.TxtBillToAddr = ConcatAddress([BillAddr1], [BillAddr2], [BillAddr3])
Me.TxtBillToCityZip = ConcatCityZip([BillCity], [BillState], [BillZip])

This does not work of course, nor does
ConcatAddress([qrySalesHeader].[BillAddr1], ...

What is the right syntax?

2.If Me.TxtBillAddress = Me.txtShipAddress Then
Subreport.txtUnitCost = 0
subreport..ExtendedCost = 0

Cant figure out how to set these values programatically.
I recall that the syntax was something like
Reports.Subreport.txtUnitCost.Value = 0
but I cant recall the exact syntax and am stumped.

(I remember the help files used to have detailed information on this but not
in the current versions...
What a pity.)

So, can someone help! Please!

Thanks and regards
Habib



Subreport
 
What's wrong with leaving the control source with the function? Your code
may not work because it can only reference values from controls in the
report. Use of fields alone will not work.

Your second question seems like you are attempting to assign a value to a
control in the subreport from the main report. I doubt this is possible.
Perhaps if you had some reason for this, we could suggest an alternative.
 
Hi Duane,
Thanks for the reply.
No, There is nothing wrong with leaving the control with the function.
This was a more of an academic exercise - to see if I could programatically
set the values of a field at run time, much like in a form.

Second question:
I am creating an invoice and the idea is to set the unit price and Extended
price of the lineitems to zero or ****
when the customer's address <> ship address - indicating a gift

I guess I'll have to work around that limitation.
I suppose I link the header to the detail table and add a flag for hiding
these and make the changes in teh sub report.

Anyway, the point is: There must be a mechanism where data can pass between
Main and subreports - subtotals come to mind as an example, and I wanted to
use that functionality. So, how does is data passed from Main to sub or sub
to main report?

Regards
Habib
 
1) I can see why you would want the experience of coding but I would use the
function as a control source in Forms also. Generally, if I don't need code,
I don't use it.

2) You can link the main table into the subreport's record source. This
allows you to use any of the fields from the main table.

BTW: I would consider adding a field indicating an order was a "gift". If
the customer address and ship address are the same seems like an odd way to
determine if something is a gift or not.
 
Thanks Duane.
I am actually just adding a small barcoding application to a diverse system
that uses multiple order capture systems and accounting systems.
Yes, I would prefer to have a field - and have created just that using a
query.

Thanks for the advice. It is good to get my feet wet again with access
reports.

Regards
Habib
 
Back
Top