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

Problem after closing report form 3

Status
Not open for further replies.

kamweng

Programmer
Jan 20, 2012
36
MY
Code:
		OREPFORM = CREATEOBJECT("Form")
WITH OREPFORM
   .WINDOWSTATE = 2
   .SHOW()
ENDWITH
REPORT FORM XXX PREVIEW WINDOW (OREPFORM.NAME)
OREPFORM.RELEASE()

After issuing the above code, I noticed all my existing variables reverted to the default values (as shown in the debug).

Is it true the “close” button also reset all the variables? If yes, how to I prevent the existing variables from being reset so that I can continue like before I issued the REPORT FORM?

Thank you.
 
Your question isn't completely clear.

What variables are you referrng to? Local variables in the routine that open the report? Variables created in the report itself? Or what?

And which Close button are you referring to?

And what do you mean by reverting to their "default values"?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I have the same question as Mike.

I can add Reports don't modify prexisting variables, unless you do so, eg by calling functions in report control expressions. Like any code, reports can influence everything. You're the master of this, if you develop the report.

Normally variables are used in a report to print them unchanged, or use them in a printwhen condition. Also reports have report variables, they don't exist after the report has run, they are, as the name says report variables.

Bye, Olaf.
 
Sorry for not being clear.

I’ve been pondering on Olaf’s reply
Reports don't modify preexisting variables, unless you do so.

Yes, he is right (I’ve rechecked them).

My app is running fine except that I’m trying to shift my hard-coded receipt printout to the report writer.

My problem is that after issuing the above REPORT FORM code, I’m unable to continue using the main form because if I were to click on any of the controls on the main form, my existing variables are reset to their initial values, that is, character as ‘ ‘, numeric as 0 and logical as .F.. I did try THISFORM.REFRESH() but this made no difference.

On the other hand, if I comment the REPORT FORM portion and use my hard-coded reports, I can still work the controls on the main form without affecting the existing variables. By the way, I didn’t issue any other code after the “OREPFORM.RELEASE()”.

I’ve searched this forum but didn’t see others having the same problem. I hope you can help me make my app truly VFP.

Thank you.
 
Kamweng,

It's still not clear what variables you are referring to.

Are you referring to variables that were created in the function or procedure that calls REPORT FORM? If so, are you aware that these will go out of scope when that function or procedure has finished executing, that is, after the OREPFORM.RELEASE()?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The an answer has to be in the report. Your code merely creates a new form (which doesn't change or reset vars), shows it (which doesn't change or reset vars), runs a report with it as preview window ((which doesn't change or reset vars, unless the report does), and then releases this preview window.

We can't help you without knowin what is happening in the report.

Look into:
1. The reports data environment. There can be code in it.
2. Report controls. There can be function calls in it.
3. Report Variables
4. Report data sessyion, is it private or not?
4. If in doubt USE your.frx and see if you find calls in it.

Then of course inspect the code called from the report.

On the other side, if you talk about variables defined in your main form buttons click code, eg by LOCAL, then of course these variables reset to .F. Variables don't keep their value forever, typically they are released after code has run, that's not only true for local, but also undeclared variables, which are then private.

I wonder if you really talk about variables, but talk about form control values, eg textbox value, or form properties.

If you issue a refresh and the report has moved to EOF of the table you report, that may mean you don't stay on the record your form showed previous to the report, but then you also don't have reset variables, you have another record and of course all bound controls on your form now show no value anymore. Eg use some table, then go bottom, then Skip 1, now read any field value, eg ? Eval(FIELDS(1)), it would be an empty string, 0 or NULL, an empty date, whatever the field type is, as you are after EOF of the table.

Bye, Olaf.
 
If you can follow Olaf's suggestions you may be able to solve your issues.

I will add some more options for your debugging purposes. Declare your form variables in the .load() of the form as follow

Code:
thisform.addproperty("f_VariableName","Value")  && read more in the help file.

Try to test one or two variables and see if they retain the values.

If they still get reset, maybe the objcode gone corrupt.


nasib


 
I guess you are creating a form from within an other main form. And the variables are reset when you call OREPFORM. if that is the case:

Then add a form OREPFORM to the project and add all the code and controls necessary.
Then call it as follow from within your main form. (There may be other ways to do this as well.)

Code:
do form OREPFORM

Your variables will remain intact.

nasib
 
Olaf, A star for you. I didn't know report data session should be private!

Nasib, A star for you too because without this,
Declare your form variables in the .load() of the form
my report form is not visible. All this while, my form variables are in the .activate()!

Mike, you deserve a star too because you taught me to ask myself deeply whether others can understand my problem. That is why it took me 2 weeks to reply to your question!

Once again, Thank you to all of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top