×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Not suppressing blank lines
4

Not suppressing blank lines

Not suppressing blank lines

(OP)
Hello colleagues!

I have created a report which has 20 detail rows:



When processing the report I want to remove lines which have no data in each field, so I set the Properties, Print When tab, for each field to:
1) Print field only when data>0
2) Remove blank line


But when I process the report, the blank lines are NOT suppressed!

Am I missing anything?

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Hi,

Perhaps your data field value is not 0 but null?

Regards, Gerrit

RE: Not suppressing blank lines

Perhaps you don't have the fields set to float, maybe they are set to relative to the top of the band?

** edit **
From your screenshot, on the general tab, in object position.

If a line in the middle was blank, the next line would stay where it was if not set to float
Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

RE: Not suppressing blank lines

Hi,

Not Only LcO10 has to be blank but also ALL the other objects on that line

From the help file

Quote:


When a field in a report band is blank or the field in the underlying table is empty, Visual FoxPro checks the report band for other report controls. If no other controls exist in the report band, Visual FoxPro removes the entire line. ...

hth

MarK

RE: Not suppressing blank lines

You haven't created a report, but rather a list of 20 sets of variables. A report will at design time only show details from one record.

RE: Not suppressing blank lines

I think Tore has the reason. If your detail band looks like this, the whole band is "one line". And if only some of the fields are not blank, then the whole area gets printed and nothing is removed or collapsed.

The other reason is, that 0 is empty, but not blank. Blank really means nothing to print in a whole line of the report. I think even if this is all one detail band it would suppress empty lines, too. But as MarK said, only if the whole line is blank. If I look closely at the first elements of each line, then I see the start of the lines vary by a bit, if the report elements all swim a bit from an exact grid position, you don't define lines very well. One element having its top over the bottom of the elements in the previous line would cause that above line to be printed, etc.

Anyway, it screams for redesign with just one line of all elements and a record per line instead of one detail band that covers multiple lines filled in with data of one record. You should really think about a data AND report design where 1 record means 1 line of the report.

Chriss

RE: Not suppressing blank lines

(OP)
Tore:

Yes, it is a report, because each record has indeed 20 lines, or 6 fields each record (120 fields each record).


Griff and Chriss:

I set all field to Float now, but with fields in same position on the report .


Chriss:

You said

Quote:

"The other reason is, that 0 is empty, but not blank. Blank really means nothing to print in a whole line of the report."

So I have to try this now. But as 3 fields in each line are Numeric, read from records in a file, how to transform 0 to blank?

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Hi,


0 (zero) in a numeric field is considered as EMPTY - please have a look et the help file.

Quote:


When a field in a report band is blank or the field in the underlying table is empty...

CODE -->

x = 0
?empty(x)

x = 0.00
?empty(x) 

hth

Mark

RE: Not suppressing blank lines

Quote:

how to transform 0 to blank?

Assuming the underlying data source is a read-write cursor:

BLANK Field1, Field2, ...

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Not suppressing blank lines

What are you quoting MArk.

We talk about the "remove line if blank feature:

Quote (help)

Remove line if blank
Specifies that the report engine may contract the report band vertically if the evaluation of the report control results in no renderable content, and no other renderable controls occupy the empty space on either side of the control.
A 0 is renderable content, it's the character "0" and it's not blank.

This is really about having no dot, no tiny tidbit of ink or toner to print in a line. And not about VFPs concepts of EMPTY() or BLANK().

There are options to let a numeric field display nothing, if it is 0:


The question is, if you want that in case there is other data and text in the line and you want 0 to print as 0 in that case. There is no magic setting that does that. The best option then will be to have a character field that you set to transform(numericfield) and then decide whether a 0 should be turned into space or not. All in a report prepass of the data yyou want to report.

Your major issue still is that you use a record that has fields for multiple lines, though, you should redesign the report table to only have one record per line. Otherwise all other efforts don't play out anyway.

Chriss

RE: Not suppressing blank lines

SitesMasstec,

Suggestion - Try this:

Uncheck [Remove line if blank]

[Print only when expression is true]
NOT ISBLANK(Ico10)

Steve

RE: Not suppressing blank lines

The thing is, even if everything on the No. 5 line is blank, the number 6 line will still print in the same place unless they
and the ones below them are all floating, not fixed relative to the top of the band.

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

RE: Not suppressing blank lines

Griff, that might be true, but only plays a role because the design is so broken to have report field in multiple lines that are all fed by one record of the report driving workarea.

Only have one line in the detail band, and the float setting won't matter. For each record the band will not print, if it is blank. That's how to best make use of this.

Chriss

RE: Not suppressing blank lines

Maybe Chris

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

RE: Not suppressing blank lines

(OP)

Dear colleagues:

All fields (and labels) in Detail section are now set to Float.
Yes, each record has data for up to 20 lines. And I can have up to 10 records in the temporary table (TEMPEXPL.DBF).

Steve: NOT ISBLANK(Ico10) shows error.

Chris: I set Format, 'Blank if zero' for Numeric fields, but it hasn't worked, also.

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Quote (SitesMasstec)

Yes, each record has data for up to 20 lines. And I can have up to 10 records in the temporary table (TEMPEXPL.DBF).
Well, thanks for that information, but it's not "yes", that's the no go of your report, that makes it not work in respect of "remove line if blank.

What you need is a data structure that has one record for one row of the report.

Chriss

RE: Not suppressing blank lines

Instead of running the report from a table, run it from a cursor. You can do whatever you want with this cursor, in your case you must make sure that there's one record per line in the report. IOW the cursor will not correspond directly to your table, instead it will correspond to your report. This will make the report much easier to create, and you will solve your problem easily.

RE: Not suppressing blank lines

(OP)

My table TEMPEXPL.DBF can have up to 10 records. It is about Production Order, that means ONE Production Order can request to Production Food kitchen (bakery, restaurant, etc) 10 recipes. Let's say a Chocolate Cake is one of the requested recipes.

The Chocolate Cake recipe is recorded in just one record.
In that record it has up to 20 itens used to produce the Chocolate Cake:
1. Flour
2. Chocolate powder
3. Sugar
etc

So, each record in the TEMPEXPL.DBF store up to 20 items about a particular food Production Order (example Chocolate Cake).

Please see the application:
This is one example of Production Order (up to 10 recipes):


And this is one recipe (Chocolate Cake), with "exploded" ingredients:


Tore: a cursor? I have never used this, I will try to use it in the application, thanks.

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Hi,

All the records of one row have to be blank. "Remove line if blank" has to be checked for all fields in a row and "Blank if 0" has also to be checked for numeric fields.

I uploaded the code with the report in the zipfile Sites.7z. You may download it and run the code, first without any changes and then emptying the values of street, areacode and town of one or more records to see its behavior.

Enjoy

MarK

RE: Not suppressing blank lines

(OP)

Mark said:

Quote:

All the records of one row have to be blank. "Remove line if blank" has to be checked for all fields in a row and "Blank if 0" has also to be checked for numeric fields.

Yes, Mark, I did this for all labels and fields of the Detail section of the report.

Note that, as I showed in the example above, just ONE record in the TEMPEXPL.DBF is made of 20 rows.

Maybe, as Chris said above

Quote:

What you need is a data structure that has one record for one row of the report.

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Hi

Quote:


Yes, Mark, I did this for all labels and fields of the Detail section of the report.

Then I don't understand why it's not working. Could you show more of your report design - not the result?

MarK

RE: Not suppressing blank lines

In addition to all the other suggestions, you need to make sure that things are lined up exactly right. For each row in the report, select all the fields and labels and choose Format | Align | Align Horizontal Centers from the menu. Then, make sure none of the lines overlap. If even one pixel from a row that has data overlaps into the line you want to blank, it won't blank.

Tamar

RE: Not suppressing blank lines

(OP)

Thank you,
SitesMasstec

RE: Not suppressing blank lines

(OP)

Tamar, as you advised, I have just correct the aligment for some fields. Also, for a better report presentation. I have not seen some incorrectly positioning. Thanks.

But the report hasn't considered blanked lines, yet,

Thank you,
SitesMasstec

RE: Not suppressing blank lines

...

Is this all part of the DETAIL BAND?

MarK

RE: Not suppressing blank lines

Have you set "Remove line if blank" for all fields? If just one field has set this and others in the same line not, then this never will result in a removed blank line.

And again, if you design a band with so many fields that are all printing data coming from one record, you have to ask yourself who's causing the pain of needing to put so many fields on the report.
A band is printed repeatedly for each record and so you make a design where you have one line of fields only and have as many records in your report data as you need to get to whatever number of lines your report will have.

It's quite similar to not having 20x5 fields in a table to feed 20x5 textboxes on a form but have a table with 5 fields and a grid with 5 columns.

You're causing your own troubles.

Chriss

RE: Not suppressing blank lines

(OP)

Chris:

I understand perfectly what you have said and I have used the way you said since FoxPro 2.0: only one row of fields in the Detail section of the report.

But the application I am working now uses a file which has in EACH RECORD 120 fields just to be used in the Detail section:



Thank you,
SitesMasstec

RE: Not suppressing blank lines

To rephrase what I already have said: Select the data from your table into a cursor, or maybe an array is even easier. Then manipulate the cursor/array so that you have one record/element per line. You can even make sure that only the info that you need in your report goes into this cursor/array.

You are wasting your (and ours) time by NOT realizing that the existing data structure is a very bad design.

RE: Not suppressing blank lines

Hi,

Your report looks more like an Excel sheet and raises a lot of questions - e.o. where do the math operations come from.

Hence, one last hint: remove all labels and fields from the detail band that are NOT part of the 20 desired rows (fields 8 - 127) and put those on the page header/footer and try again.

Furthermore, if you're working a lot with VFP reports, I recommend

The Visual FoxPro Report Writer: Pushing It to the Limit and Beyond - Paperback – January 1, 2002
by Cathy Pountney (Author), Dave Aring (Editor)

hth

MarK

RE: Not suppressing blank lines

SitesMAsstec,

and I perfectly understand that this is the structure of the data, but as Tore said you have to preprocess it for the report, so that one record only has data of one line of the report. Even if you have to live with the data structure as it is, if it's not your design, you can always move data from where it is into a new cursor to drive the report. And there's no way around that if you want to get to the removed lines.

Chriss

RE: Not suppressing blank lines

It occurs to me that you might also have a constant band height for your detail section.

Right click on the detail band bar, then pick properties and on the general tab there is a constant height option.

If you were to post a sample of the data and the frx/frt files... we could look for other things...

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

RE: Not suppressing blank lines

(OP)

Hello colleagues!

I can imagine how you may be tired with my question, based on how tired I am in order to find the solution.

I am going to order the book Mark suggested to read, thank you.

Griff: "constant height option" in the report has been unchecked.

Below you can find the shared link for the report and a file linked to it (Data environment). This is a simplified report from the original one, but it reflects the same problem: do not remove blanked lines.

Link

Thank you,
SitesMasstec

RE: Not suppressing blank lines

I have given you the advice you need, but you seem to refuse to follow it.

Just one hint: Where your "report" has 20 rows, it should only have ONE! And each row should contain data from ONE record! So you need to convert your table, the easiest is to copy the table to a cursor, and manipulate that cursor. For an experienced VFP programmer that cursor manipulation should take a minute or two to program. And then the report will take a few milliseconds to run.

RE: Not suppressing blank lines

I wish you good luck with trying to get this report layout working in terms of "remove line if blank".

I can only encourage to experiment to find out if something does or does not work in principle.
Here's a report that mimics the minimal "design flaw" (as I would call it) to have multiple lines of the same structure in a detail band:

And the data comes from this (indeed I first created the cursor to design the report with it):

CODE

Create Cursor reportcursor (line1 char(200), line2 char(200))
Insert into reportcursor values    ('report line  1',;
                                    'report line  2')
Insert into reportcursor values    ('' ,; && blank report line 3
                                    'report line  4')
Insert into reportcursor values    ('report line  5',;
                                    '')   && blank report line 6
Insert into reportcursor values    ('' ,; && blank report line 7
                                    '')   && blank report line 8
Insert into reportcursor values    ('report line  9' ,;
                                    'report line 10') 
The code is intentionally formatted this way so each line of the code corresponds to one line of the report. So you see without removing blank lines the report would have a gap line between line 2 and 4 and a gap of 3 lines between line 5 and 9.

The detail band is not set to constant height, as Griff suggested (it wasn't anyway, a constant band height isn't a default).
Both fields "line1" and "line2" have been set to "remove line if blank" in the print when tab. I didn't set the fields to "float" but kept them at the default of "fix relative to top of band". The report print like this:

So, fantastic news, you could stick to your report and data design. But it's still only working if all fields have been set to "remove line if blank". If you only set this in just one of the fields of a line, this one field doesn't determine the removal of the whole line when just it is blank. VFP reports only remove lines that are really fully blank, that's only working when all fields of a line contribute to that by a) being blank and b) having the "remove line if blank" setting checked. And even if that is all set correctly, what can then still hinder it all to work is if fields are packed too tight vertically and if their top position doesn't align exactly, each diversion from that can make it count as another line of the report, again.

It remains a flaw to me to have such a design, both in report and in data, but that's now not hindering it to work technically.

Chriss

RE: Not suppressing blank lines

2
Hi SitesMasstec,

I had a look at your report.

You have to make sure that ALL the fields of the table you do not wish to be printed are blank, even those with letters like E, R, Kg ... - e.g. from Lor01 till Lvr01 or Lor05 till Lvr05

Furthermore you'll have to check the "Remove line if blank" and empty the box "Print only when ... " for ALL fields in the detail band on the report (I did it for the first 5).

Additionally I moved the static info (labels etc) up to the page header and the footer and modified the report to start each record on a new page.

I uploaded a zip file SitesBakery.7z with the modified table (some fields are blanked), a prg and the report files. You unzip the file run the prg, click on Print Report et voilà.

Good luck - there is much work to do.

N.B. You may however want to rethink the structure of your table - you have too many empty fields per record. But that's another topic.

hth

MarK

RE: Not suppressing blank lines

Dear SitesMastec,

In a row in your report layout, instead of placing multiple field controls, place only a single control with following expression:

lor02 + IIF(lco02>0, STR(lco02, 6), SPACE(6)) + lno02 + IIF(lqt02>0, STR(lqt02,10,3), SPACE(10)) + lun02 + IIF(lvr02>0, STR(lvr02,12,3), SPACE(12))

Check 'Remove line if blank'.

Repeat same for all your rows.

By the way, if you're not using a mono spaced font, your columns may not be aligned. In such situations, the monospace font I always like is 'Consolas'.

Rajesh

RE: Not suppressing blank lines

Dear SitesMastec,

Or, you can create a cursor like:

CODE -->

SELECT ;
lor01 + IIF(lco01>0, STR(lco01, 6), SPACE(6)) + lno01 + IIF(lqt01>0, STR(lqt01,10,3), SPACE(10)) + lun01 + IIF(lvr01>0, STR(lvr01,12,3), SPACE(12)) as reprow_1 ;
,lor02 + IIF(lco02>0, STR(lco02, 6), SPACE(6)) + lno02 + IIF(lqt02>0, STR(lqt02,10,3), SPACE(10)) + lun02 + IIF(lvr02>0, STR(lvr02,12,3), SPACE(12)) as reprow_2 ;
...
...
...repeat this for each row by changing 03..04...05 and so on.
...add whatever other fields you need...
...
INTO CURSOR cRepData READWRITE 

Then use this cursor as data for your report. Now, your first row field control expression would be 'reprow_1', for second row, 'reprow_2' and so on. Here also, check 'Remove line if blank' for each row.

Rajesh


RE: Not suppressing blank lines

Hi,

In a report fields may be lined up horizontally or vertically or both - just think about labels for envelopes.

I admit, the layout is a little bit unusual but it works fine - just have a look at the zip file.

Sites... just has to follow my hints (see my previous post)

hth

MarK

RE: Not suppressing blank lines

I spent a few minutes, and wrote this simple program to convert your table into a cursor. This cursor is ideal to drive the report. You may have to add a few more fields, or you can link this cursor to the table using the common field lcodi.

For your report this means that you only use one line in the detail band. In the details band, rename all the xxx01 fields to curreport.xxx, and delete the rest.

CODE

Local lcX, lnX, loRecord

Create Cursor CurReport (;
  lcodi n(6),;
  lor c(1),;
  lco N(6),;
  lno c(40),;
  lqt N(10, 3),;
  lun c(2),;
  lvr N(12, 3))
Scatter Name m.loRecord
Select Select('tempexpl')
Use tempexpl
Scan
  m.loRecord.lcodi = lcodi  
  For m.lnX = 1 To 20
    m.lcX = Padl(m.lnX, 2, [0])
    m.loRecord.lor = Evaluate([lor] + m.lcX)
    m.loRecord.lco = Evaluate([lco] + m.lcX)
    m.loRecord.lno = Evaluate([lno] + m.lcX)
    m.loRecord.lqt = Evaluate([lqt] + m.lcX)
    m.loRecord.lun = Evaluate([lun] + m.lcX)
    m.loRecord.lvr = Evaluate([lvr] + m.lcX)
    If m.loRecord.lqt > 0
      Insert Into CurReport From Name m.loRecord
    Endif
  Endfor
Endscan
Select CurReport
Browse Normal 

This code also make sure that empty fields are not copied to the cursor. IOW, no need for any "blank if empty" in the report.

RE: Not suppressing blank lines

To give you another reason for the separation of data of the report lines into separate records. If you intent to remove lines of ingredients that have a zero amount, then that's easy with a FOR clause using FOR amount>0. But if you have fields for up to 20 ingredients in one record ou can't skip a record if it has some of those 0 amount ingredients. You could only skip a whole record if all quantitis wold be 0. It's a natural need not only driven by database normalization theory, to have a record for an ingredient. I don't even know why anybody would get the idea to design such horrible records.

So in short even if you'd not filter data as Tore did with If m.loRecord.lqt > 0, you can run the report with filtered data. It all becomes so much simpler, if rows of the report are also records of the data, and you always can prepare a report cursor, no matter how the data is structured.

Chriss

RE: Not suppressing blank lines

Hi SitesMassTec,

Did you find a solution to your problem?

FB would be appreciated

MarK

RE: Not suppressing blank lines

(OP)
Hello colleagues!

Dear Mark and everyone who has helped me a lot:

Yesterday I downloaded the SitesBakery.7z file provided by Mark and after unzipping the files, I executed the sample. It was like magic for me, despite the fact that I work with Visual FoxPro since 2002 (VFP 6, then VFP9, and many books from Hentezenwerke); but I came from FoxPro 2 for MS-DOS, and I am afraid I had not opened widely my mind to the possibilities of VFP9!

I have never used Cursor, because temporary "hard" files (like TEMPEXPL.DBF in this thread) have worked fine for me, but, now I will use Cursor (yes, it is simpler), thanks to your advice.

Well, I am now reviewing all the posts to apply the advices to my project.

I will give notice here as soon as I solve the problem (of course, using Cursor, among other changes).

Thanks from my heart.

Thank you,
SitesMasstec

RE: Not suppressing blank lines

Hi Sites...

I took the data from the table you provided, normalized them and copied them into a cursor to drive the report. You may download the 7z file from Engineering.com, extract it and run testgridbaker.prg.

I left you some work to do (designing the report) wink . Nevertheless Enjoy!

hth

MarK

RE: Not suppressing blank lines

Thanks for the feedback, SitesMasstec.

The restructuring of data just as it is ideal for a report is not depending on using either cursor or DBF file, though. Tore's code would also extract the single records from your data, if it started with CREATE TABLE instead of CREATE CURSOR, for example.

Cursors are just very commonly used by Foxpro programmers, as you very often only need data temporally. And you need it in another form as you have it in DBFs. It actually is normal to split up data even though it belongs together and then need to join it back together. It's the ability to join in many ways for many aspects and points of views, which also give views their name.

To describe it in the topic of recipes and ingredients, a good database design is storing data in the same manner as you prepare food at the start of cooking a recipe, you prepare the base ingredients, for example, peeled and diced or sliced vegetables, called "Mise en Place". And then you put them together for a salad, a bowl, a pizza, a cake or whatever you want to make of it. And you join the different ingredients as needed. Data is usually not the convenient food you just use as is and put into a microwave or oven. It's normal to need to combine data to something "consumable".

The art is not designing the DBFs so you later only need to open one DBF for form or a report. It is indeed to store the data prepared to be easily combined as necessary for those forms and reports and the actual composition printed is usually only needed temporarily.

Chriss

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close