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!

PageFrame & Memvar Problem 1

Status
Not open for further replies.

stanmurphy

Technical User
Oct 14, 2000
89
Hello All,

I have a modal form with a 2-page pageframe and a Private Datasession. Each page contains a number of check boxes. All the check boxes use memvar variables scattered from a single file as their controlsource.

My problem is that the memvars for the check-boxes on page two keep disappearing from memory. When I suspend and check immediately after the scatter, they are there. But when I resume and check just after focusing on a combobox, the memvars associated with the fields on page 2 of the pageframe have disappeared. There is no code between the scatter and the setfocus to the combobox, and no code in the combobox either.

One clue I have is that if I move one of the check-boxes from page 2 to page 1 of the pageframe, that check-box works fine.

Does anyone know why those memvars are disappearing?

 
They're probably going out of scope. Did you try declaring them public or initializing them in a start up routine?
Dave S.
 
If they were going out of scope, wouldn't they all go out? It's just the last 20 out of 57 that are disappearing, and they were all scattered at the same time from the same record.
 
They would go out of scope when another page was active, since they are local to that particular page.
Dave S.
 
Ok, so it's a 2-page pageframe. Each page has checkboxes. I scatter the table variables from the parent form. At the point when I click the Save button on the main form to save the variables, all the memvars referenced on the second page of the pageform disappear. What makes them do that? How does the scope change? I'm still on the same form.
 
This is the code in the CLICK event of the SAVE button on the form that contains the pageframe:

**************************************************

IF EMPTY(ALLTRIM(thisform.TEXT1.value)) OR EMPTY(ALLTRIM(thisform.TEXT2.value))
MESSAGEBOX("Client Name Must Be Entered",0,"MISSING INFORMATION")
RETURN .f.
ENDIF

SELECT appt
SET ORDER TO BYALL

&& CHECK IF THE COUNNAME OR DATETIME HAS CHANGED - IF SO, DELETE OLD RECORD AND SAVE NEW ONE
IF ALLTRIM(THISFORM.pCOUNNAME)<>ALLTRIM(THISFORM.COMBO1.Value) ;
OR THISFORM.pAPPTDATETIME<>THISFORM.TEXT4.VALUE

SEEK(ALLTRIM(THISFORM.pCOUNNAME)+TTOC(THISFORM.pAPPTDATETIME,1))
IF FOUND()
REPLACE NEXT 1 APPTDATETIME WITH DATETIME(1960,07,10,12,00,00), CLIENTLAST WITH &quot; &quot;, CLIENTFIRST WITH &quot; &quot;
DELETE NEXT 1
GO TOP
ENDIF
ENDIF

SELECT APPT
SET ORDER TO BYALL
SEEK(ALLTRIM(THISFORM.COMBO1.VALUE)+TTOC(THISFORM.TEXT4.Value,1))
IF FOUND()
GATHER memvar
ELSE
APPEND BLANK
GATHER memvar
ENDIF

replace NEXT 1 lrecordlocked WITH .f., cLockedBy WITH &quot; &quot;, NOTYETSAVED WITH .F.

GO top

thisform.Release
*********************************************
 
stanmurphy

I think its because you are moving your record pointer and also you may want to check the debugger to see if your memvar are still there. If you lose them you want to beck back to that recno() and re-issue a scatter memvar at the end of your save routine. Or avoid all this FPW style coding and use the VFP way of doing things and use controlsources for your controls and never have to deal with memvars going out of scope. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
The problem I have been having on controlsources for a recent client is that he INSISTS on not saving record changes before a saved button is pushed. I need a good rollback routine for edits and new records.

Frank
 
The problem I have been having on controlsources for a recent client is that he INSISTS on not saving record changes before a saved button is pushed.

Huh? Records are not saved until you hit the save button, using buffering mode. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
It's okay, you got me back on track. Check the obvious first, and I didn't.

Frank
 
Hi stanmurphy,

After you SCATTER MEMVAR the record you wanted..

ThisForm.Refresh() may be done by you. But this is not enough.
You have to do..
ThisForm.PageFrame1.Page1.Refresh()
ThisForm.PageFrame1.Page2.Refresh()

And proceed with your activity. You should not be facing the problem. I felt this thread got side tracked as against your problem. But may be I am stupid. But worth a try :)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
When are you doing your SCATTER? Unless you are making them public, they go away after leaving the procedure.
For example, if you have the scatter in say, the Init method of the form, as soon as the Init finishes the variables are gone.
Dave S.
 
My scatter is done in the WHEN event of an invisible button on the parent form that has TabIndex of 1. After the scatter, the eventcode of the button sends the focus to the first visible control. Is there a better way?

I will try your suggestion ramani and report back.

Thanks everyone.
 
When I need to access variables in different areas of the form, I either make them as form properties or initialize them in the 'main.prg' that calls the form:

SCATTER MEMVAR
DO FORM MyForm
CLEAR EVENTS

That way they are visible to 'child' methods/procedures.
Dave S.
 
Hi StanMurphy..

That is information to me again..
The invisible property will not solve your problem..

Try my suggestion and also make the Text.Visible to .t.
You can probably put the following code

Text1.When

This.Top = -50
SCATTER MEMVAR
ThisForm.PageFrame1.Page1.Refresh()
ThisForm.PageFrame2.Page1.Refresh()
RETURN .f.


That will fix your problem :) When event may not fire with Visiblity is .f.

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
The problenm was fixed by declaring the variable PUBLIC in my Main.prg

Thank you everyone for your assistance. I always learn so much when I come here!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top