Ack!! Holy Cow!

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I gave up and decided to put all the fields into one
table. It's much easier to manipulate for me as a newbie.

After I did that. I was setting up my report when I
happened to cut and paste some of the fields on the report
to different areas.
Much to my shock I discoved that if you cut something from
the "DETAILS" section. Then paste it into the "HEADER"
section. It will only show the current record!
Exactly what I've been knocking myself silly trying to do
with VBA code.



The answer was sooooo simple. :-)


-Scott
 
I would do a little testing if I were you. I imagine you will always report
the last record in your table/query based on some possibly arbitrary sorting
of records.

If you want to print a report based on the current record, you can describe
the current record in code and use this in the Where clause of the
OpenReport method. For instance if you have a numeric primary key field that
is bound to the text box "txtID" on your form, the code might look like

DoCmd.OpenReport "rptMyReport", acPreview, , "[ID]=" & Me.txtID
 
Scott said:
I gave up and decided to put all the fields into one
table.

mistake. That is what queries are for. This decision will come back and bite
you later. Trust me.
It's much easier to manipulate for me as a newbie.

go back and build a query that shows you all the fields you need and build
your report on the query.
After I did that. I was setting up my report when I
happened to cut and paste some of the fields on the report
to different areas.
Much to my shock I discoved that if you cut something from
the "DETAILS" section. Then paste it into the "HEADER"
section. It will only show the current record!

UNLESS you are showing a calculated field with a domain aggregate function
(like a sum our count field)!
If your calcualted field does not use a domain aggregate function, then it
too will show its calculation result for whatever the "current" record is
when that header/footer band is calculated. This can be both a good thing
and a bad thing, depending on what behavior you need for each particular
case.
Exactly what I've been knocking myself silly trying to do
with VBA code.

The answer was sooooo simple. :-)

Well, if that was what you were after, why didncha just say so?
Heh. 80% of the battle is learning how to ask the right questions in the
first place! :-)
 
I tried that Duane,
But all that does is limit the main fields in the report
to the current record.
Using that code the Sub Form still lists every single
record in the report.
So far none of the suggestions I've gotten will force
those Sub Form fields to print just the active record.

The only thing that worked was to place both MAIN Form And
Sub Form fields in the Header section of the report.
Nothing else works.

I know this is really bad ettiquette(sp?) doing it this
way. But it works.
I can only figure that I somehow have the table
relationships set up wrong. Because that's the only part
of Access that I really don't understand. And that's why
it's not working with VBA code.

Kinda goofy I know.
I'm comfortable with VBA coding. But Table relationships
confuse me. I'm strange. ;-)


-Scott
 
If you expect the subreport records to be limited to records related to the
record(s) in the main report, you can set the Link Master/Child properties
just like you would for Forms and Subforms.

--
Duane Hookom
MS Access MVP


I tried that Duane,
But all that does is limit the main fields in the report
to the current record.
Using that code the Sub Form still lists every single
record in the report.
So far none of the suggestions I've gotten will force
those Sub Form fields to print just the active record.

The only thing that worked was to place both MAIN Form And
Sub Form fields in the Header section of the report.
Nothing else works.

I know this is really bad ettiquette(sp?) doing it this
way. But it works.
I can only figure that I somehow have the table
relationships set up wrong. Because that's the only part
of Access that I really don't understand. And that's why
it's not working with VBA code.

Kinda goofy I know.
I'm comfortable with VBA coding. But Table relationships
confuse me. I'm strange. ;-)


-Scott



-----Original Message-----
I would do a little testing if I were you. I imagine you will always report
the last record in your table/query based on some possibly arbitrary sorting
of records.

If you want to print a report based on the current record, you can describe
the current record in code and use this in the Where clause of the
OpenReport method. For instance if you have a numeric primary key field that
is bound to the text box "txtID" on your form, the code might look like

DoCmd.OpenReport "rptMyReport", acPreview, , "[ID]=" & Me.txtID
 
Back
Top