Filling report controls thru code

G

Guest

I have made a report in design mode and put in the blank unbound text boxes
to hold the needed values. each text box is named. i have a procedure that
goes thru my tables and retrieves the sums of the values in the table, that I
need. Now I am trying to populate the text boxes in the report with the
values from my procedure.

I figured if I loaded the report and then assigned the values in the
procedure to the text boxes on the report and then opened the report. I
can't get the report loaded. I have tried Load Reports!ReportName and Load
Reports.ReportName. It says it cannot load this object.

Can any one assist?

Thanks in advance.
 
J

John Vinson

I have made a report in design mode and put in the blank unbound text boxes
to hold the needed values. each text box is named. i have a procedure that
goes thru my tables and retrieves the sums of the values in the table, that I
need. Now I am trying to populate the text boxes in the report with the
values from my procedure.

That's the HARD way to do it! Create a Query which calculates your
sums, and base the report on that Query. You might not need any code
at all.

John W. Vinson[MVP]
 
G

Guest

I have 16 tables that are not related that need to be summed, 3 tables for
income and 13 tables for expenses. I have written the code to sum them. I
have tried Sum Queries and I get astronomical figures. Can't I get all the
figures in code (Already accomplished and confirmed), Load the form ( I get
error 2461) and then programatically assign the values to the controls on the
form, then Show the form?

Would it be easier to design a table to hold my sums, populate it with the
code then open a report based on the table?
 
D

Duane Hookom

Ron,
You now have two threads going with the same question. Please try to avoid
this.

Since this now seems like a report question, I suggest this thread be
continued in the Reports NG thread with the subject "Help creating a report
programmatically"
 
J

John Vinson

I agree with Duane... it's confusing following two threads.
I have 16 tables that are not related that need to be summed, 3 tables for
income and 13 tables for expenses. I have written the code to sum them. I
have tried Sum Queries and I get astronomical figures. Can't I get all the
figures in code (Already accomplished and confirmed), Load the form ( I get
error 2461) and then programatically assign the values to the controls on the
form, then Show the form?

Your query is not working correctly, probably because you're joining
these tables. I am very queasy about your table design though! 13
tables for expenses suggests that you have a different table (all the
same structure??) for different categories of expenses, and similarly
for income. If that's the case, your table design is WRONG; much
better would be *one* income table, and *one* expense table, with an
additional field for the category of income or of expense. If the
tables have different structures, and contain different types of data,
please explain.
Would it be easier to design a table to hold my sums, populate it with the
code then open a report based on the table?

No. A UNION query might be the solution though; rather than *joining*
your 13 expense tables (which will give you multiple copies of each
record, hence the astronomical sums), use the UNION operator to string
them together "end to end":

SELECT PersonID, ExpenseAmount FROM Groceries
UNION
SELECT PersonID, ExpenseAmount FROM Travel
UNION
SELECT PersonID, ExpenseAmount FROM Entertainment
UNION
<etc etc>

See UNION in the online help. You could then save this query and base
your Sum query upon it.

John W. Vinson[MVP]
 

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