Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print report problem

Status
Not open for further replies.

gutay008

Programmer
Nov 9, 2015
34
PH
Good Day!

Anyone here already tried to print a report on a half of a bond paper and that report will duplicate its data on the other half of the bond paper? every time i used the report for of the vfp9, it always consumed the whole page. I can preview the report on a half bond paper but with a single data in the table. How about i want to print selected data on my table?
 
I'm not sure if you can do that with a report. But it should be possible with labels. A label is essentially the same as a report, but with the ability to print several copies on the same page. If you want both copies to show the same data, you will have to duplicate that data within the cursor or table that drives the report.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yeah, I can think of several ways to kludge this in a report but in every case a label form makes more sense and is what I'd use if I was doing it for myself. And IIRC, two labels on a sheet is one of the standard label sizes that ships with VFP.
 
Sir, can you give me idea on how i can start with the label you are telling about? i have no idea on previewing report with a label.
 
Either:

In the Command Window, type [tt]CREATE LABEL[/tt]​

Or:

From the menu, choose Tools / Wizards / Labels​

Or:

From the Project Manager, drill down into Documents / Labels, then click New​

Whichever method you use, you will have to choose the label layout. Pick one that shows two labels per page, and where the label size is roughly half a page.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks sir mike, i already made the label, i tried to preview my data with the label by searching and selecting the data to preview, it wont display the data i need. I think it is different with the report previewer.
 
No, the label tool works in the same way as the report designer. If your data is not showing up, it might be a problem with the way your select or filter the data, or it might be because you have errors in the expressions within the label. It's impossible to know at this distance.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
i tried to preview my data with the label by searching and selecting the data to preview, it wont display the data i need

Ok, you've said what DOESN'T happen. What does happen? What did you do to get here?

Do you get an error message?
 
Good Day!

Apologize for the late respond, as i said on my previous reply i made the label and the fields. On my first test, it display the last and 2nd to last data which is wrong, i want to display the current or the latest record which i save and duplicate on a single report. Moving on to the 2nd test, i played on the code, which is the below code

SELECT issue
SET ORDER TO id
LOCATE FOR fullname = thisform.pageframe1.page3.txtfullname.Value AND issue.desc= thisform.pageframe1.page3.txtdesc.Value
IF FOUND()
label FORM C:\BGHsystem\Report\issue.lbx PREVIEW FOR datetime = thisform.pageframe1.page3.text7.Value
ENDIF
endif

on the 2nd test, i made the report displayed the latest data which user save, but only one or half of the page, i want to display the same record on a whole sheet. I tried to locate the name and the item which is the last record, and if found i have also condition here if the datetime met that record will be previewed.

any workaround here?

i have attached sample report generated on my 2nd test.
 
 http://files.engineering.com/getfile.aspx?folder=9a95894d-77e8-4c57-a126-fa6792ef2901&file=111.png
It's still not at all clear what you are trying to achieve.

What you appear to be doing is the following:

1. You are looking to see if the table contains at least one record with a specified fullname and description.

2. If it does, you print a label for every record in the table that has a specified datatime (regardless of whether it meets the fullname/description test).

3. If the table doesn't contain a record with the specified fullname and description, you print nothing.

Is that correct? Is it what you are trying to achieve?

If, on the other hand, you want to print all records that have the specified fullname and description AND meet the datetime test, then your code won't do that. The LOCATE will only find the first record with the fullname and description; the LABEL ... FOR will find every record with the datetime, regardless of its fullname and description.

But none of that has any connection with the fact that you want to "display the same record on a whole sheet". What does that mean? I thought the whole point of your using labels was to print two records per sheet.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The one you've listed above is just my experiment to see what will be previewed. as you have suspected the code is not right for what i want to happen. AS i said i want to display one record but it will duplicate on the report. as the picture i attached lately it displays the latest record which is correct but it doesn't duplicate to fit on one whole bond paper. The thing is i want to minimized using bondpaper in every print out so i decided to duplicate so whenever they need the record i can give the other half of the print out.
 
For example the image i attached lately, presume that it is a 1 whole sheet of bond paper, the first problem is that i cannot preview the latest record which i save, but now the problem was solved. Second problem is that the record on that image is i want to duplicate to fit on 1 whole sheet of bond paper. Base on the image, it consumed only half of the page. So i want to fill the other half of the page with the same record.
 
If you want to print the same record multiple times, there are several options.

One way assumes you've included the alias (Issue, according the code you've posted above) on all report objects:
Code:
* once you've located your record in Issue
Select 0
Create Cursor Temp (temp c(1))
Append Blank
Append Blank  && if you want two copies
* With the temporary cursor SELECTED, a label will print as many labels as there are rows
* in the temporary cursor, with the Label Form pulling data from the single selected row
LABEL FORM

The other way is to create a temporary cursor containing a full copy of the desired record as many times as you want it to print, and use that to produce your labels.
 
I don't know if it helps, if I chime in, too.

If you want one record height to be higher, you have to simply make the design of the report/label higher, the height of the detail band is the height of a record and if it doesn't fill your label sheet fully, then make the report design larger, the only other thing making the output larger is when you specify "stretch with overflow", but that obviously doesn't do the stretching always, only when dataq needs more place. The general size especially with labels is determined by the label type you choose when first creating the label, so that determines the full size of the lbx.

Dan has a nice trick of how to print a current record twice. You have to understand one thing for this: The report or label always uses one table/cursor/view as the main driving cursor. The number of records it has, determines how many times the detail band is printed. Now you can specify another table/alias name for report controls, so the label driving cursor determining the number of records is not pushing in the data, but whatever current record of the alias you use in the report controls is printed multiple times, as the record pointer moves forward in the driving cursor, but stays at the same printed record.

It's a nice trick, but probably not what you want. It's still unclear to me, what you want.

What you're doing can be seen to be wrong, because you can't LOCATE and thereby move to a certain record and then also use a FOR condition. The FOR condition makes the record position jump back to record number 1 and then move to all records fulfilliung the condition you specify, so the previous LOCATE has no effect whatsover, it only makes sure some record with some condition exists, but then the for condition most probably prints other records, that's what Mike already abserved and asked, if you wanted this. Your FOR condition in the LABEL command determines what is printed, not the locate, so thats obviously wrong.

If you want to print the record you found, then specify label FORM C:\BGHsystem\Report\issue.lbx NEXT 1 PREVIEW, no FOR clause. The FOR clause means moving to other records. The FOR clause also does not start searching from the initial position, but FROM top of the table. If you want to have both a certain fullname and a certain datetime, then combine both conditions. You might also combine the LOCATE with other scopes printing from there and further on, eg NEXT 2 prints the found and next record, REST WHILE also is a possible scope printing while a condition holds true, but not FOR.

Bye, Olaf.
 
You have very detailed information about how to achieve what you need. I will try to reword it what is already said:

1. Create a report
2. shrink the header footer and any other bands (divisions) on it to 0.
3. Expand the detailed band to a full page. That is your detaild band will be 10" high giving 1/2" margin on top and bottom. Adjust it according to your requirements.
4. At height 5 1/2" (middle of the page) draw a small line marker such that you can cut/fold the paper at this point.
5. Assuming you hav 3 fields to print. Go to Report/Insert/Field and put all he the fileds on the top half of the report
6. Now copy/paste the same fields on the lower part of the report.
7. Save the report
8. In your program limit the dataset to what you want to print.
9. If you want to
a) print the current record as you have tried before then issue
report form xyz preview next 1
Only one page will be printed.
b) print next 2 record after the search then issue
report form xyz preview next 2

for other options see above posts.

Code:
* modified version of your original code
SELECT issue
SET ORDER TO id
* Instead of locate you can filter the data at this point
* I think you require 3 conditions to be true.
SET FILTER TO ;
    alltrim(FULLNAME)   = alltrim(thisform.pageframe1.page3.txtfullname.Value)  AND ;
    alltrim(issue.DESC) = alltrim(thisform.pageframe1.page3.txtdesc.Value) AND ;
    DATETIME            = thisform.pageframe1.page3.text7.value ;
    IN issue

    * LOCATE FOR fullname = thisform.pageframe1.page3.txtfullname.Value AND issue.desc=    thisform.pageframe1.page3.txtdesc.Value

LOCATE  && Check if there are any records matching above condition
IF NOT EOF() && if found()
   REPORT FORM C:\BGHsystem\Report\issue.frx PREVIEW   && FOR datetime = thisform.pageframe1.page3.text7.Value
ENDIF

SET FILTER TO
 
Good Day!

Sir NasibKalsi, thanks for the information. actually i already previewed my desired output but i did not realize earlier what if i want to issue more than 1 item? Because the problem i mentioned above was all about issuing only 1 item and viewing it on a whole sheet and also duplicate the record. what if i want to issue like 10 or 15 items with different description?

can i make it with the same idea with the code? or i will modify my report?
 
Having the report the way Nasib describes, whaat do you think will happen? The report controls are duplicated within the same detail band, a detail band prints what it's asked to print from the current record and is repeated for each record you print. So what will happen? If you can't answer that, simply try.

Bye, Olaf.
 
>with different description?

Just in regard to this, if the second half is not exactly the same data you'll have to have a separate record for this. Then the whole idea of repllcating the record is useless, no matter if repklicating the record itself or the report controls. Simply have the data you want to print and have the detail band half height of a sheet, then two records are printed per sheet, you just have to prepare the data accordingly, ie instead of creating one record, create two and change the description in the/each second record.

Bye, Olaf.
 
Hello sir olaf, i already fix the problem without the instruction of sir Nasib but the idea was the same. And thanks to sir Nasib. His code was much clearer than the code i made. About the report, i did not changed the fields or whatsoever sir Nasib was describing above. But maybe his idea was also right. In regards with the statement youre referring to sir Olaf, as i said i already fixed the replicating of data and previewing it in a single sheet. But heres another problem that what if i want to issue 2 or more supplies with different description? Maybe i can do with the code but in the reports i cannot output the for example 4 records and replicate on the other half of the bond paper. Hopefully my explanation is clear sir olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top