Multiple Detail Band in Visual FoxPro 9

Filed Under (Visual FoxPro, work.BLOG) by WildFire on 08-02-2006

After countless trials and errors, with each error pounding one of my faithful neurons, reading (and re-reading and re-reading), roundtrips to the Program Files\VFP9\Samples directory and pathetic attempts to have a crash course on 'Absorbing the Mozart Effect 101'... I finally figured out how to make VFP9's multiple detail band feature work on one of my reports.

(And no, Mozart wasn't helpful this time.)

More than 77 neurons are off to meet their maker. I stopped counting though an hour and a half ago, so there's probably more. (And we're not even counting the injured and now-limb-less ones.)

Yes I know... I'm quite late with this. Most VFP9 coders are now using the multiple detail band to extract data from different databases located in parallel universes while I have been using the dump N table records to one 'cursor/table holder' with generic field names where I can extract data for reporting...

... or firing up CrystalReports.

Anyway at 1:37AM, I'm scribbling this down just in case an alien decides to teleport its presence here in this room, do some wholesome (I hope) experiments and decides to mind-wipe me afterwards, which might possibly corrupt this multiple-detail-band-eureka moments I have.

Also this could probably help a coder out there who decides to google things after being mind-wiped by an alien.

Just a basic overview... I'll call these step by step 'hints' not a 'guide'. (A User Guide expert would scream bloody hell when he sees this. (But trust me a programmer will understand. (Especially those mind-wiped by aliens.)))

Parent.dbf / Child01.dbf / Child02.dbf
Right click = Right click in the Report Designer.



File. New. New report. (No wizards.)




Data Environment. Add the three (or more) tables.




Set the relationships. (P » C01 and P » C02.)




Right click. Select Data Grouping.




Data Grouping tab. Group Nesting Order box. Add. And add field from your parent table (Your primary key... for example: PARENT.CODENO)




Right click. Optional Bands. In the Detail Bands box, Add another Detail Band.




Now you have two bands. One for you, one for the alien.




Double click on the Detail 1 separator. The Detail Band Properties window pops out. (Or if you like the longer process... Report... Edit Bands... select Detail 1.)




Check Associated header and footer bands. (Trust me you need this. Aliens are allergic to this.)




Repeat steps 8 - 9 for Detail 2.




Data Environment. Drag the fields to their appropriate bands. Parent fields on the Group Header. C01 fields in the Detail 1 band and C02 fields on the Detail 2. And aliens in the footer part.




BTW... you should have saved your report already and instinctively press CTRL+S every now and then in case the aliens...




Now double click the Detail 1 'bar' (separator) again.




Detail Band Properties. In the Target alias expression enter 'child01' or the name of your child database. (NOTE: Be sure to include the '')




Do the same with the other Detail bands. The Detail 1 band separator should now look like 'Detail 1: Child01'.




Add appropiate headers, lines and all. Align things.




Beautify your report. Make it look professional. Nevermind if your clients are using a stone-age dot matrix printer.


Hope this helps.

Now I'm off to re-inspect the protective shields of this room.