Dee
asked on
Keep browse windows open until user closes them
I am opening a browse window, running some processes, then calling another program that opens a 2nd browse window.
I need them both to stay open until the user closes them.
If I just open one, it stays open. If I open 2, they both flash on the screen then are closed.
select table1
go top
browse fields field1, field2, field 3 nowait
Call Program2
*-Program 2
select table2
go top
browse fields field1, field2, field 3 nowait
I need them both to stay open until the user closes them.
If I just open one, it stays open. If I open 2, they both flash on the screen then are closed.
select table1
go top
browse fields field1, field2, field 3 nowait
Call Program2
*-Program 2
select table2
go top
browse fields field1, field2, field 3 nowait
ASKER
"The code influence - Each BROWSE window closes automatically when the underlying table is closed so the alias becomes"
..... I am likely closing the table(s) somewhere .. I have searched high and low..
Here's the whole kit and kaboodle. -- You will recognize a good chunk of the code Dear Pcelba :)
************************** ********** ******
*- ckBreedRemindScrub.prg
************************** ********** ******
lparameter lcThisPath, lnWeekNum
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
if empty(lnWeekNum)
lnWeekNum = 36
endif
close datab all
local lcScrubFile
lcEditFile = (lcThisPath) + "ckBreedEdit"
do (lcThisPath) + "ckbreed_update" with lcThisPath
do (lcThisPath) + "ckRemindLabel_update" with lcThisPath
do (lcThisPath) + "ckBreedRemind_update" with lcThisPath, "A", lnWeekNum
************************** ********** ******
*- ckBreed_Update.prg
************************** ********** ******
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
set default to (lcThisPath)
do (lcThisPath) + "ckBreedCombine" with lcThisPath
select ckBreedEdit
scan
if not deleted() && deleted('scrubFile')
update ckBreedScrub ;
set breed1 = ckBreedEdit.Breed1 ;
where breedd = ckBreedEdit.breedd and ;
speciesd = ckBreedEdit.speciesd and ;
species = ckBreedEdit.species and ;
breed = ckBreedEdit.breed
else
lcBR = alltrim(upper(breedd))
delete from ckBreedScrub where alltrim(upper(breedd)) = lcBR
endif
endscan
************************** ********** ******
*-ckBreedCombine.prg
************************** ********** ******
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
set safety off
use (lcThisPath) + "\breedlist.dbf" in 0 shared
USE (lcThisPath) + "\breedlist.dbf" IN 0 AGAIN ALIAS Breedlist_a SHARED
use (lcThisPath) + "\breedmaster2.dbf" in 0 exclu
use (lcThisPath) + "\breedmaster2.dbf" in 0 AGAIN ALIAS Breedmaster2_a SHARED
select breedlist_a
set order to tag ubreedd
brow last for len(alltrim(breed1))>3 nowait
select breedmaster2
set order to tag ubreedd
brow last nowait
USE (lcThisPath) + "templates\" + "ckBreedEdit.dbf" in 0 shared
select ckBreedEdit
COPY STRUCTURE TO (lcThisPath) + "\ckBreedEdit.dbf"
use in ckBreedEdit
use (lcThisPath) + "\ckBreedEdit.dbf" in 0 shared
select breedmaster2
set order to tag ubreed3
select ckBreedEdit
set relation to upper(substr(breed,1,3)) into breedmaster2 additive
set relation to upper(substr(breed,1,3)) into breedlist_a additive
select speciesd, species, breedd, breed, count(*) as cnt from (lcThisPath) + "ckBreedScrub.dbf" group by species, speciesd, breed, breedd order by species, speciesd, breed, breedd into table ztemp.dbf
Select ckBreedEdit
Append from ztemp
index on upper(breedd) tag ubreedd
index on upper(substr(breedd,1,3)) tag ubreed3
index on upper(substr(breed,1,3)) tag ubr3
set order to
go top
browse last fields cnt:R, species:20:R, speciesd:20:R, breed:20:R, breedd:40:R, breed1:20;
nowait
************************** ********** ******
*-ckBreedLabel_Update.prg
************************** ********** ******
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
do (lcThisPath) + "ckRemindLabelDetail" with lcThisPath
do (lcThisPath) + "ckRemindLabelCombine" with lcThisPath
use (lcThisPath) + "ckRemindEdit" excl
SELECT ckRemindEdit
INDEX ON alltrim(DefaultDir)+Descri p TAG DirDescrip
SET ORDER TO TAG DirDescrip
LOCAL lnI, lcField, lcVal, lcSeekExpr
*------------------------- ---------- ---------- ---------- ---------- ---
* ckbreedlabel_update.prg
*
* writes label edits back to scrub file
************************** ********** ********** ********** ********
use in select('ckbreedScrub')
use (lcThisPath) + "ckBreedScrub.dbf" in 0 alias scrubfile
SELECT scrubfile
*-- Go through all records one by one and replace fields one by one in inner loop
SCAN ALL
FOR lnI = 1 TO 8
*-- Field name of the updated field
lcField = IIF(lnI = 1, 'descriptn', 'descrip' + ALLTRIM(STR(lnI)))
? lcField
*-- Original value of the updated field
lcVal = EVALUATE(lcField)
*-- Value with ClientId used to seek the row in Label table
lcSeekExpr = alltrim(DefaultDir)+lcVal
REPLACE (lcField) WITH IIF(SEEK(lcSeekExpr, 'ckRemindEdit'), ckRemindEdit.Label, lcVal)
NEXT
ENDSCAN
************************** ********** ******
*- ckRemindLabelDetail.prg
************************** ********** ******
lparameter lcThisPath
if empty (lcThisPath)
lcThisPath = "c:\vetdata\_DE\vetdata\"
endif
SELECT defaultdir, prrecno, "descriptn" as col, descriptn AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descriptn) and (descriptn = "-" and not descriptn = "-- Cur")) ;
or (descriptn = "XXX");
UNION ALL ;
SELECT defaultdir, prrecno, "descrip2" as col, descrip2 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip2) and (descrip2 = "-" and not descrip2 = "-- Cur")) ;
or (descrip2 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip3" as col, descrip3 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip3) and (descrip3 = "-" and not descrip3 = "-- Cur")) ;
or (descrip3 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip4" as col, descrip4 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip4) and (descrip4 = "-" and not descrip4 = "-- Cur")) ;
or (descrip4 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip5" as col, descrip5 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip5) and (descrip5 = "-" and not descrip5 = "-- Cur")) ;
or (descrip5 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip6" as col, descrip6 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip6) and (descrip6 = "-" and not descrip6 = "-- Cur")) ;
or (descrip6 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip7" as col, descrip7 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip7) and (descrip7 = "-" and not descrip7 = "-- Cur")) ;
or (descrip7 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip8" as col, descrip8 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip8) and (descrip8 = "-" and not descrip8 = "-- Cur")) ;
or (descrip8 = "XXX") ;
into table (lcThisPath) + "ckRemindLabelDetail"
************************** ********** ******
*-ckRemindLabelCombine.prg
************************** ********** ******
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
USE (lcThisPath) + "templates\" + "ckRemindEdit.dbf"
select ckRemindEdit
COPY STRUCTURE TO (lcThisPath) + "\ckRemindEdit.dbf"
USE IN SELECT('ckRemindEdit') &&close table
use (lcThisPath) + "\ckRemindEdit.dbf"
select ckRemindEdit
select defaultdir, descrip, count(*) as cnt from (lcThisPath) + "ckRemindLabelDetail.dbf" group by defaultdir, descrip order by descrip into table ztemp.dbf
Select ckRemindEdit
Append from ztemp
replace all label with descrip
go top
brow last fields cnt, defaultdir :R, descrip :R, Label nowait
..... I am likely closing the table(s) somewhere .. I have searched high and low..
Here's the whole kit and kaboodle. -- You will recognize a good chunk of the code Dear Pcelba :)
**************************
*- ckBreedRemindScrub.prg
**************************
lparameter lcThisPath, lnWeekNum
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
if empty(lnWeekNum)
lnWeekNum = 36
endif
close datab all
local lcScrubFile
lcEditFile = (lcThisPath) + "ckBreedEdit"
do (lcThisPath) + "ckbreed_update" with lcThisPath
do (lcThisPath) + "ckRemindLabel_update" with lcThisPath
do (lcThisPath) + "ckBreedRemind_update" with lcThisPath, "A", lnWeekNum
**************************
*- ckBreed_Update.prg
**************************
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
set default to (lcThisPath)
do (lcThisPath) + "ckBreedCombine" with lcThisPath
select ckBreedEdit
scan
if not deleted() && deleted('scrubFile')
update ckBreedScrub ;
set breed1 = ckBreedEdit.Breed1 ;
where breedd = ckBreedEdit.breedd and ;
speciesd = ckBreedEdit.speciesd and ;
species = ckBreedEdit.species and ;
breed = ckBreedEdit.breed
else
lcBR = alltrim(upper(breedd))
delete from ckBreedScrub where alltrim(upper(breedd)) = lcBR
endif
endscan
**************************
*-ckBreedCombine.prg
**************************
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
set safety off
use (lcThisPath) + "\breedlist.dbf" in 0 shared
USE (lcThisPath) + "\breedlist.dbf" IN 0 AGAIN ALIAS Breedlist_a SHARED
use (lcThisPath) + "\breedmaster2.dbf" in 0 exclu
use (lcThisPath) + "\breedmaster2.dbf" in 0 AGAIN ALIAS Breedmaster2_a SHARED
select breedlist_a
set order to tag ubreedd
brow last for len(alltrim(breed1))>3 nowait
select breedmaster2
set order to tag ubreedd
brow last nowait
USE (lcThisPath) + "templates\" + "ckBreedEdit.dbf" in 0 shared
select ckBreedEdit
COPY STRUCTURE TO (lcThisPath) + "\ckBreedEdit.dbf"
use in ckBreedEdit
use (lcThisPath) + "\ckBreedEdit.dbf" in 0 shared
select breedmaster2
set order to tag ubreed3
select ckBreedEdit
set relation to upper(substr(breed,1,3)) into breedmaster2 additive
set relation to upper(substr(breed,1,3)) into breedlist_a additive
select speciesd, species, breedd, breed, count(*) as cnt from (lcThisPath) + "ckBreedScrub.dbf" group by species, speciesd, breed, breedd order by species, speciesd, breed, breedd into table ztemp.dbf
Select ckBreedEdit
Append from ztemp
index on upper(breedd) tag ubreedd
index on upper(substr(breedd,1,3)) tag ubreed3
index on upper(substr(breed,1,3)) tag ubr3
set order to
go top
browse last fields cnt:R, species:20:R, speciesd:20:R, breed:20:R, breedd:40:R, breed1:20;
nowait
**************************
*-ckBreedLabel_Update.prg
**************************
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
do (lcThisPath) + "ckRemindLabelDetail" with lcThisPath
do (lcThisPath) + "ckRemindLabelCombine" with lcThisPath
use (lcThisPath) + "ckRemindEdit" excl
SELECT ckRemindEdit
INDEX ON alltrim(DefaultDir)+Descri
SET ORDER TO TAG DirDescrip
LOCAL lnI, lcField, lcVal, lcSeekExpr
*-------------------------
* ckbreedlabel_update.prg
*
* writes label edits back to scrub file
**************************
use in select('ckbreedScrub')
use (lcThisPath) + "ckBreedScrub.dbf" in 0 alias scrubfile
SELECT scrubfile
*-- Go through all records one by one and replace fields one by one in inner loop
SCAN ALL
FOR lnI = 1 TO 8
*-- Field name of the updated field
lcField = IIF(lnI = 1, 'descriptn', 'descrip' + ALLTRIM(STR(lnI)))
? lcField
*-- Original value of the updated field
lcVal = EVALUATE(lcField)
*-- Value with ClientId used to seek the row in Label table
lcSeekExpr = alltrim(DefaultDir)+lcVal
REPLACE (lcField) WITH IIF(SEEK(lcSeekExpr, 'ckRemindEdit'), ckRemindEdit.Label, lcVal)
NEXT
ENDSCAN
**************************
*- ckRemindLabelDetail.prg
**************************
lparameter lcThisPath
if empty (lcThisPath)
lcThisPath = "c:\vetdata\_DE\vetdata\"
endif
SELECT defaultdir, prrecno, "descriptn" as col, descriptn AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descriptn) and (descriptn = "-" and not descriptn = "-- Cur")) ;
or (descriptn = "XXX");
UNION ALL ;
SELECT defaultdir, prrecno, "descrip2" as col, descrip2 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip2) and (descrip2 = "-" and not descrip2 = "-- Cur")) ;
or (descrip2 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip3" as col, descrip3 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip3) and (descrip3 = "-" and not descrip3 = "-- Cur")) ;
or (descrip3 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip4" as col, descrip4 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip4) and (descrip4 = "-" and not descrip4 = "-- Cur")) ;
or (descrip4 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip5" as col, descrip5 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip5) and (descrip5 = "-" and not descrip5 = "-- Cur")) ;
or (descrip5 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip6" as col, descrip6 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip6) and (descrip6 = "-" and not descrip6 = "-- Cur")) ;
or (descrip6 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip7" as col, descrip7 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip7) and (descrip7 = "-" and not descrip7 = "-- Cur")) ;
or (descrip7 = "XXX") ;
UNION ALL;
select defaultdir, prrecno, "descrip8" as col, descrip8 AS Descrip FROM lcThisPath + "ckBreedScrub" WHERE ;
(NOT EMPTY(descrip8) and (descrip8 = "-" and not descrip8 = "-- Cur")) ;
or (descrip8 = "XXX") ;
into table (lcThisPath) + "ckRemindLabelDetail"
**************************
*-ckRemindLabelCombine.prg
**************************
lparameter lcThisPath
if empty(lcThisPath)
lcThisPath = "c:\vetdata\_de\vetdata\"
endif
USE (lcThisPath) + "templates\" + "ckRemindEdit.dbf"
select ckRemindEdit
COPY STRUCTURE TO (lcThisPath) + "\ckRemindEdit.dbf"
USE IN SELECT('ckRemindEdit') &&close table
use (lcThisPath) + "\ckRemindEdit.dbf"
select ckRemindEdit
select defaultdir, descrip, count(*) as cnt from (lcThisPath) + "ckRemindLabelDetail.dbf" group by defaultdir, descrip order by descrip into table ztemp.dbf
Select ckRemindEdit
Append from ztemp
replace all label with descrip
go top
brow last fields cnt, defaultdir :R, descrip :R, Label nowait
ASKER
Oops .. I guess I should tell you specifically where the issue is ...
ckBreedCombine.prg's browse window should stay open until the user closes it.
Then the browse window in ckremindlabelcombine.prg should open and stay open until the user closes it.
Both browse windows do so if the program's are called individually.
*****
ckbreedcombine.prg
*****
select ckBreedEdit
..
..
..
browse last fields cnt:R, species:20:R, speciesd:20:R, breed:20:R, breedd:40:R, breed1:20;
*****
ckremindlabelcombine.prg
*****
select ckRemindEdit
..
..
..
brow last fields cnt, defaultdir :R, descrip :R, Label nowait
ckBreedCombine.prg's browse window should stay open until the user closes it.
Then the browse window in ckremindlabelcombine.prg should open and stay open until the user closes it.
Both browse windows do so if the program's are called individually.
*****
ckbreedcombine.prg
*****
select ckBreedEdit
..
..
..
browse last fields cnt:R, species:20:R, speciesd:20:R, breed:20:R, breedd:40:R, breed1:20;
*****
ckremindlabelcombine.prg
*****
select ckRemindEdit
..
..
..
brow last fields cnt, defaultdir :R, descrip :R, Label nowait
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
pcelba, Thank you for you response.
I am still working on this and will have post some follow up questions later today.
Thanks!
I am still working on this and will have post some follow up questions later today.
Thanks!
ASKER
I am sorry for the delay in getting back to this.
I did find a couple of USE commands that I did not include in 0.
Those being added, the issue persisted.
I traced it down to the last program call, ckbreedremind_update.prg where I discovered a CLOSE DATABASE ALL command. I had added this at some point when I was testing the program and forgot to take it out.
Thank you pcelba :)
I did find a couple of USE commands that I did not include in 0.
Those being added, the issue persisted.
I traced it down to the last program call, ckbreedremind_update.prg where I discovered a CLOSE DATABASE ALL command. I had added this at some point when I was testing the program and forgot to take it out.
Thank you pcelba :)
Yes, CLOSE DATABASES ALL is good for general cleanup but not in the middle of any code :-).
Glad to help.
Glad to help.
Environment - If you are in VFP development IDE (where the Command Window is available) then it should work. If you are talking about the VFP application compiled to EXE then there should be READ EVENTS command which ensures the browse window (with NOWAIT clause as you've correctly added) to stay open during the program run or until user closes it. Of course, the program flow stops on the READ EVENTS command until appropriate CLEAR EVENTS command is issued or until the program ends. Menu selection or code invoked by ON KEY commands
The code influence - Each BROWSE window closes automatically when the underlying table is closed so the alias becomes unavailable. And this is valid even the alias becomes unavailable for a fraction of the second.
So the answer is in your code. It could help if you show more lines.