Report & Subreport Does Update always

G

Guest

I have a Main report with 4 subreports. The four subreports have a master
and child link. On my main report, I am using VBA code to update four text
boxes on the main report to different values that that want the various
subreport to link.

Then I select the report and do a preview, the subreport doesn't appear with
any results (they are not appearing).

I then click on View (which takes to to the design view of the main report)
and I then click of the View button (which previews the main report again).
The results of the subreports appears on the main report.

I have my VBA Code in the section before I need it in the "On Format" event.

I do see the results in the 4 text boxes correctly, but it doesn't get used
in linking to the subreports.


Can someone please help !!!! I have been trying different things for 2
days.
I assume the next boxes need values before I start, but I have no ideal what
is really wrong and how to resolved this issue.


Thank You,

Gary

On the following pages, the subreports are appearing in both cases.
 
A

Al Campagna

Gary,
Sounds like the record you've been editing has not been updated, or
refreshed, before you try the report.
Those 4 values are only written to the table when an Update or Refresh
has occured.

The fact that you go into design mode, and back to form view... and the
report is OK... is due to design mode "forceing" an Update. So would
closing the form and reopening it. So would moving to another record, and
back again.

Try using the AfterUpdate of each of the 4 fields to do a Refresh. Then,
when the report runs, those values should have updated in the supporting
table, and be displayed on the report. If not... then you have another
problem.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."
 
G

Guest

Setting the values of the text boxes with code in the on format event is a
bit unusual. Can't you set the values in the record source rather than with
code?

If you can't do this without the code solution, try requery the subreport
after you set the value of the text boxes that are the Link Master.
 
A

Al Campagna

Gary,
Duane brought up a point I missed in your post.
If you are programatically updating the four fields, you'll need to do a
Refresh within that VB code.
Programatically setting the value for a text control does not fire that
control's AfterUpdate event.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."
 
G

Guest

In my VBA code, after I completed setting the four Text boxes with values, I
then did a requery of each f the 4 subreports. Refresh is not available for
reports.

It doesn't work correctly. When I preview the main report, it is still
missing the information from the subreport.

Someone indicated that Subreports opens first, and my text boxes are not set
by VBA code yet.

You indicated that why was I am not able to use a recordsource (i.e. query
or table). I need the top four items of each main item. Sometime, the main
item only has 1 item, 2, etc.

As I am writing this, I guess I can (using on open even) generate a table
like that and have the main report bounded to that table???

Any suggestions??


Thanks You,


Gary
 

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