How do I add field from field list at run time

K

Krish

Hello!

Any body can help me how do I get fields and add the field
with its control source from my report's field list at run
time. I want to specify its x,y position also, whenever I
open a report.

Thanks for help.

Krish
 
J

James Brown

Hi,

We once did a customisable report where the user could select (at runtime)
what fields they wanted to show, and the report showed them and
automatically arranged them. To do it we showed all fields on the report
but made them invisible. When the report was opened it looped through all
of the fields that were specified by the user, found the matching field on
the report, made it visible and put it at position x. Position x was then
incrememented by the width of that field.

It sounds like you could do something similar. If you don't know what
fields are *available* until runtime then you've got a slight complication,
but not an impossible one - just set the ControlSource property of the field
at runtime.

Jamie.
 
K

Krish

Hi,

Thanks for your response. Yours solution sounds well if i
know all the fields before. But I dont know how many
number of fields i will have. I am using crosstab query.
So problem with this query it changes as per the data in
the base table. old fields may be deleted new fields may
add. I can keep more number of text boxs and according to
the incoming fields i can change the control source of
each. But I am searching for some better solution, so that
what ever is the number of fields my programe can
dynamically manage without any proble. Please let me know
if you find any solution.

Krish
 
K

Krish

H! Jamie,

Thanks for your reply and interest you are showing on my
problem. Actually I am working on developing an accounts
package. Now it will be clear to you that account heads
may varry from time to time as per the bills. Explaining
hole thing is difficult. So I am explaining the problem
here in simple. Hope you can easily understand.

My table is having Group Ledger (under which I add
subledger accounts and its details). Below I am giving a
sample table structure for better understanding.

ID Group Ledger Sub Ledger Amount V Date

1 Stationary Books Rs. 400 1-1-03
2 Fee M.Tech Rs. 10000 1-1-03
3 Fee Ph.D Rs. 25000 1-2-03
4 Scholarship M.Tech Rs. 5000 1-3-03
5 Stationary Pens Rs. 100 1-5-03

Now from the above table I need a report like below.

V Date Stationary Fee Scholarship
1-1-03 400 10000 -
1-2-03 - 25000 -
1-3-03 - - 5000
1-5-03 100 - -
-------------------------------------
500 35000 5000
-------------------------------------

From the above you can easily understand that the columns
will increase (columns are fields incase of crosstab
query). Now my problem is after designing a report from a
crosstab query some columns may increase or some columns
may not come for the next financial year. So how do I
manage the situation dynamically.

I am troubling you. But your solution will help me a lot.

Looking forward to your reply.

Thanking you,

Krish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top