By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

Combining Lines In a Report

P: n/a
Hello everyone,

I have an agency report where the lines looks something like this:

Agency Code Percent Sold Total Premium
------------------------------------------
J1 50% $1000
GT 45% $750
L2 20% $300

I need to create a way so that the user can select which agencies to
combine before running the report. They should be able to combine
2,3,4 agencies together and leave other agencies uncombined.

For instance, lets say they want to combine agencies (on runtime), L2
and GT in the above example. The report should now look like:
Agency Code Percent Sold Total Premium
------------------------------------------
J1 50% $1000
GT,L2 65% $1050

Can anyone suggest the best way of doing this? I was thinking a form
where they select which agencies get combined and then using recordsets
to combined and rewrite the reports dataset.

Hope I was clear enough.

Thanks,
Brian

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Brian,
That is a pretty ugly process.
How good are you at coding forms? If you can do that you are in good
shape. Here are my two cents.
Table1:
AgencyCode PercentSold TotalPremium
j1 $0.50 1000
gt $0.45 750
l2 $0.20 300
z3 $0.30 400

Table2:
AgencyCode
J1
Gt,l2

If you set up your form so that you have two list boxes side by side
with buttons between them like the form wizard when you choose fields.
Create a table to hold your combo agencies (table2 in this example).
List1 shows the agencies that are not used, List2 shows the
combinations, you can have the buttons move the data between them.
Moving an item from List1 adds it to the table that List2 shows.
your List1 qry could look like this:
SELECT Table1.AgencyCode
FROM Table1, Table2
GROUP BY Table1.AgencyCode
HAVING (((Sum(InStr([Table2].[AgencyCode] & ",",[Table1].[AgencyCode] &
",")))=0));

Your report recordset would look like this:
SELECT Table2.AgencyCode, Sum(Table1.PercentSold) AS PercentSold,
Sum(Table1.TotalPremium) AS TotalPremium
FROM Table1, Table2
WHERE (((InStr([Table2].[AgencyCode] & ",",[Table1].[AgencyCode] &
","))<>0))
GROUP BY Table2.AgencyCode;

If you can get most of the way there and you get stuck on the form
code, post it and ask again. :)
Hope that helps you
Pachydermitis

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.