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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 9 Report Builder "File In Use"

Status
Not open for further replies.

blanca1331

Technical User
Jun 14, 2021
8
MY
I'm currently working on a .frx report that shows the result as below

Prodcode

ITEM A
ITEM B
ITEM C
ITEM B

Now I want the records to be sorted in ascending order, hence I created a .prg file with the code as below

SORT ON Prodcode TO MYTABLE1
USE MYTABLE1


Whenever I execute this .prg file in my .frx report, I noticed that the result did sorted in ascending order but at the same time I will receive error message "file in use" which required me to force close my application to get rid of this error message.

Can anyone let me know what went wrong?
 
 https://files.engineering.com/getfile.aspx?folder=5f91fe83-1197-4599-94ab-733dd2a3da62&file=WhatsApp_Image_2021-06-15_at_12.10.24_AM.jpeg
Don't create a sorted file, just set an index SET ORDER TO tagname and then report in that sortorder.

Chriss
 
Hello Chris Miller !

Could you provide me an example or sample on how to do it?

Sorry I am very newbie in vfp : (
 
You may already have indexes on the table, then all you need is

Code:
USE Table
Set Order To whatever
REPORT FORM ...

To see whether an index on prodcode exists you can look for defined indexes in the table designer:

Code:
USE Table
MODIFY STRUCTURRE

Often an index on a single field is named the same as the field. If you see no index, then you can use the table desinger to create it. That's only necessary once and it's kept up-to-date with any change of data.

Then setting order takes no time, while SORT TO always creates a new DBF. That's most probably also the reason you get the File in Use error, as you still have the previous version of Mytable1.dbf open. There's no need to copy all data into a new DBF file to sort it, just use an index.

Chriss
 
If no order is set and no index is created, the running order is:

Use...
Index on xxx tag xxx
Set order to tag xxx
Report...

Regards, Gerrit
 
Hello Chris Miller,

I noticed that there is no .dbf tables file from my application folder, I'll assume the .dbf tables is embedded into my .exe application and will only be loaded whenever I proceed to preview the reports in my application. (Refer to attachment)


 
 https://files.engineering.com/getfile.aspx?folder=1e0b772d-2ad6-4bc9-8cef-d6bb6defa3fa&file=WhatsApp_Image_2021-06-15_at_9.25.20_AM.jpeg
DBFs are usually stored elsewhere. In AppData folders.

But let's assume you're right, then you can create an external DBF file that way and have it sorted at the same time. You just should not reuse the same name unless your previous run is complete including printing and deleting the previous file. Your problem only occurs because you still have MYTABLE1.DBF and have it open.

So try
Code:
SORT ON Prodcode TO MYTABLE1
USE MYTABLE1
REPORT FORM
USE IN MYTABLE1
ERASE MYTABLE1.*

That can be used repeatedly.

Chriss
 
Hello Chris Miller !

I just tested out your code in my application, it delete the files but it deleted the file too quickly which caused missing table when I attempt to preview the report ....

Is there a way to only delete the MYTABLE1.dbf file after I exit from the preview report screen?

Thank you
 
 https://files.engineering.com/getfile.aspx?folder=1e0b772d-2ad6-4bc9-8cef-d6bb6defa3fa&file=WhatsApp_Image_2021-06-15_at_9.25.20_AM.jpeg
Hm,

REPORT FORM has to be adjusted to your needs, of course, with the FRX name and including the PREVIEW clause when you want a preview.
When you do that the next line (ERASE) will not execute before the report finished.

Just test this with an existing report:
Code:
REPORT FORM HOME()+'TOOLS\FILESPEC\90FRX.FRX' PREVIEW
MESSAGEBOX('finished')

I printed using a PDF printer and the PDF is created before the Messagebox appears.

So what's not working for you with what exact code adjustment?


Chriss
 
Hello Chris Miller,

Below is my current code that is not working in my application

SORT ON Prodcode TO MYTABLE1
USE MYTABLE1
REPORT FORM rptsinv1_summary.frx PREIVEW NO WAIT <<< (Return an error message "Report contains a nesting error")
USE IN MYTABLE1
ERASE MYTABLE1.dbf
ERASE MYTABLE1.fpt


The rptsinv1_summary.frx file is already inside my application and database folder.
 
REPORT FORM HOME()+'TOOLS\FILESPEC\90FRX.FRX' PREVIEW
MESSAGEBOX('finished')

How do I insert this block of code into my current code?

I do not have the file 'TOOLS\FILESPEC\90FRX.FRX' available ...
 
This isn't meant to be your new code, this demonstrates how a REPORT ... PREVIEW is executed before the next line of code.

Your error is to use NO WAIT. You actually DO want to wait before the next code executes.


Chriss
 
One more thing,

blanca1331 said:
REPORT FORM rptsinv1_summary.frx PREIVEW NO WAIT <<< (Return an error message "Report contains a nesting error")

No idea why you have a nesting error, the help on that error message says it means an expression/function used within in the report calls REPORT FORM, which can't work.
You have to fix that first, before fixing the "File is in use" error.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top