IT SOLUTIONS
Your full service technology partner! 
+Expand
   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardObjectPAL Topic   Print This     

Multi-form questions

Multi-form questions in ObjectPAL topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: questions   Multi form   Multi form questions  
harrymossman
Sacramento, CA USA
I have 2 forms. On form 1, the user makes a selection from a table, then pushes a button which opens form 2. This is my attempt to get around not being able to filter detail tables on a form. In other words, form 1 acts as a filter. This all works fine, if form 2 isn't already open.

My question is how to check whether form 2 is open and close it if it is. Or manipulate the tables in form 2 with it open.

Harry
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
The form successfully enummerates the open forms, then procedes to run the rest of the code without closing the other form.

Harry

enumFormNames(openForms)
openForms.view()

if openForms.contains("fund_search_step2") then

if not f.attach("fund_search_step2") then
errorShow()
return

else

if not
f.close() then
errorShow()
endIf

endIf

endIf
Complete code:

method pushButton(var eventInfo Event)

var

qD,qT,qP query
tblVarD,tblVarT,tblVarP Table
f Form
tblToIndexD,tblToIndexT,tblToIndexP String
indexedFieldsD Array[] String
indexedFieldsT Array[] String
indexedFieldsP Array[] String
openForms Array[] String


endVar

qFund = selected_fund.value ;Fund on which to query. Tilde variable.

qFundName = fund_name.value

;Chech whether 2nd form is already open. If so, close it.
enumFormNames(openForms)
openForms.view()

if openForms.contains("fund_search_step2") then

if not f.attach("fund_search_step2") then

errorShow()
return

else


if not
f.close() then
errorShow()
endIf

endIf

endIf


;Find deposits into selected fund
qD = Query

ANSWER: :work:selected_fund_dep.db

sp_fund_dep.DB | LogYr | Log# | Fundid | Transaction Date | Amount Dep |
| Check | Check | ~qFund | Check | Check |

sp_fund_dep.DB | Credits | Comments |
| Check | Check |

EndQuery

;Find transfers out of selected fund
qT = Query

ANSWER: :work:selected_fund_trans.db

sp_fund_trans.DB | LogYr | Log# | Fundid | Bankid | Transaction Date | Amount Transfered |
| Check | Check | ~qFund | Check | Check | Check |

sp_fund_trans.DB | Credits | Comments |
| Check | Check |

EndQuery


;Create table containing all deposit and transfer log numbers
qP = Query

ANSWER: :work:selected_fund_proj.db

sp_fund_dep.DB | LogYr | Log# | Fundid |
| Check | Check | ~qFund |

EndQuery


;Execute queries
if not executeQBE(qD) then


errorShow()

endIf

if not executeQBE(qT) then

errorShow()

endIf

if not executeQBE(qP) then

errorShow()

endIf


;Index Deposits
tblToIndexD = ":work:selected_fund_dep.db"

if isTable(tblToIndexD) then

tblVarD.attach(tblToIndexD)
if not tblVarD.lock("Full") then
msgStop("Stop!","Can't lock "+tblToIndexD + " table.")
return

endIf

;Primary index
INDEX tblVarD

Primary
ON "LogYr","Log#","Transaction Date"

ENDINDEX

;Secondary index
INDEX tblVarD

MAINTAINED
ON "LogYr","Log#"
TO "LogNum"

ENDINDEX


else
msgStop("Stop!", "Can't find " + tblToIndexD + " table.")

endIf


;Index Transfers
tblToIndexT = ":work:selected_fund_trans.db"

if isTable(tblToIndexT) then

tblVarT.attach(tblToIndexT)
if not tblVarT.lock("Full") then
msgStop("Stop!","Can't lock "+tblToIndexT + " table.")
return

endIf

;Primary
INDEX tblVarT

Primary
ON "LogYr","Log#","Bankid","Transaction Date"

ENDINDEX

;Secondary
INDEX tblVarT

MAINTAINED
ON "LogYr","Log#"
TO "LogNum"

ENDINDEX


else
msgStop("Stop!", "Can't find " + tblToIndexT + " table.")

endIf

;Index Project numbers
tblToIndexP = ":work:selected_fund_proj.db"

if isTable(tblToIndexP) then

tblVarP.attach(tblToIndexP)
if not tblVarP.lock("Full") then
msgStop("Stop!","Can't lock "+tblToIndexP + " table.")
return

endIf

INDEX tblVarP

Primary
ON "LogYr","Log#"

ENDINDEX


else
msgStop("Stop!", "Can't find " + tblToIndexT + " table.")

endIf

writeEnvironmentString("Fund",fund_name.value)

;Go to form 2
f.open("M:\\PDOXDATA\\LOG\\COMP\\fund_search_step2")

close()


endMethod
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
>>Is the form(s) you are trying to close WAITing on another form, by chance?

No. Only these 2 forms are open. I know that because the code enumerates them.

>>I noticed that you have error trapping in place around the closing code. Did you get an error message?

No, just messages saying that the queries couldn't be run because the answer tables are in use (by the 2nd form).
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
Whew!

>>Wait

For testing I open the 2nd form from the Project Viewer. It does not have any queries. It does have a code to call the 1st form (see below). However, I usually open the 1st form separately from the Project Viewer to simulate someone starting up without realizing that they have left form 2 open. Anyway, I get the same results no matter how I open the 2 forms.

method pushButton(var eventInfo Event)
var
f form
endVar
f.open("M:\\PDOXDATA\\LOG\\COMP\\fund_search")
close()
endMethod
>> close

The second has almost no code. Aside from the button mentioned above, there is a simple close() button and a button that open()s another form. (I haven't pushed that button more that about once during testing.)

Form 2 is really just 3 tables. The master table is the log number, the other 2 are deposits and transfers. All of them are read-only so the form doesn't do much of anything except pull the tables together for the user to scroll through.

>>openForms testing

OK, it says it is not finding the form name.

>>Locks

Not sure what to do with this idea. Would I somehow have the second form not set locks?

So, I think the most obvious place to start is to figure out why the openForms testing doesn't find the second form.

Thanks for all your help!
Harry
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
Well, the good news is that I did have an old name for form 2 in the code. [Duh]

The bad news is that even carefully inserting the right name, with exact capitalization, etc., didn't help. [Sigh]
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
>>write the contents of that formnames array to a text file

I know this is probably a basic procedure but it's something I don't know how to do. In looking through my books to find out how to do it, I came across two examples of using for endFor to look through enumFormNames arrays for a form name. Should I be doing that?

I tried to write a loop using Mike's example (see below) but when the syntax checker gets to the 2nd line, it stops at openForms and says "unknown method name."

for siCounter from 1 to openForms.size()
if openForms(siCounter) = "sp-fund-tracking2" then
msgInfo("Reminder","Form 2 was left open. Closing it.")
if not f.attach("sp-fund-tracking2") then
errorShow()
return

else

if not
f.close() then
errorShow()
endIf
endIf

else msgStop("Error","Form name not found")
return


endIf
endFor
>>Do you still get the message that it doesn't find the form name?

Yes

Harry
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
>>Copy and paste the contents of forms.txt into a message here, if you would. Then we'll all be talking apples.

Form : fund_search.fsl
Form : fund_search_step2.fsl
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
harrymossman
Sacramento, CA USA
Bingo! Geek Alert!

Thanks Mac and Jedstar. I probably would have been fired long ago for throwing my computer out the window or something if it wasn't for this forum.
 Posted 22 years ago (Thread Starter)
Comment Quote
About harrymossman +Expand
Location=Sacramento, CA USA 
Joined=25 years ago   MB Posts=83  
Langley McKelvy
Harris County Texas, USA
Try this:

var
openForms Array[] String
endVar
;
enumFormNames(openForms)
;
if openForms.contains("the form name")
then ;code goes here
endif
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Sorry, didn't finish. Anyway that code will tell you if the form is open. Then use a form variable to attach to the form. I think you can close it once it is attached. Never tried to manipulate tables that way, though. Unless someone else answers up, you may have to experiement.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
I noticed that you have error trapping in place around the closing code. Did you get an error message?
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
I just tested the basic code and have no problem making it work. I don't see anything wrong with your code, so I'm betting the the form was opened with a Wait, as Tony said.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
I think what Jedstar and I mean is: How was the form you want to close opened in the first place? If it was opened like this (i.e. you used a button expert to open it):

someForm.open()
someform.wait()

then the WAIT might be causing the problem.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Another thought is that you may have some code attached to the close or canClose event of the form, or some object on the form, which is preventing it from closing when it does not have focus.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Oh - no, I wouldn't think so, but he said there were only two forms open.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
I had one other thought. If you aren't getting any error messages, then it seems your code is failing on the first IF condition. Try making this minor change and see what happens:

if openForms.contains("fund_search_step2")
then if not f.attach("fund_search_step2")
then errorShow()
return
else if not f.close()
then errorShow()
endIf
endIf
else msgStop("Error","Form name not found")
return
endIf
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Yeah, you are right. Maybe if he tried closing the form manually it would toss an error message he could use?
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Yeah, you are right. Maybe if he tried closing the form manually it would toss an error message he could use?
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
>>OK, it says it is not finding the form name.

Okay - now we are cooking. When you do your view() of the enumerated forms, look for the form name in there. Attach to that form name, which is the TITLE value of the form in the object explorer's Appearance Tab, not its actual file name.

Mac
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Do you still get the message that it doesn't find the form name?
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Langley McKelvy
Harris County Texas, USA
Okay - you never gave the forms a title, because these are defaults. The form name is everything you see there, 'Form : fund_search_step2.fsl'.

Just to simlify things a bit, try changing the title property (in the object explorer) of the 2nd form to something simple but meaningful, like: TestMe. Then try your code again, inserting that name as the form name.
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Most Recent Post
Langley McKelvy
Harris County Texas, USA
Whew! You're welcome Harry. :)
Mac

[i]"A king will have his way in his own hall, be it folly or wisdom."[/i] - Gandalf
 Posted 22 years ago
Comment Quote
About Langley McKelvy +Expand
Location=Harris County Texas, USA  
Joined=23 years ago   MB Posts=387  
Tony M
 (Inactive)
Is the form(s) you are trying to close WAITing on another form, by chance?
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Probably doesn't have anything to do with it, but you are setting 3 "FULL" locks on tables.

I don't see you releasing those tables.

Could it be that they are still locked?

Depends on where your 'other' form/code comes into play.
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Mac,

I was actually thinking...

When you enumerate those forms, if the one you attach TO and try to close has opened another form, and is waiting on it, can an outside form/construct then close() it?
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Harry,

How are each of the forms being opened?

One opened by the other?

Is the one containing that pushbutton opened by the other?

Is the 'fund_search_step2' form WAITing on the one with the pushbutton code?

What was 'fund_search_step2' doing prior to this form trying to do something?

Is there a query in 'fund_search_step2' also?

Was 'fund_search_step2' editing? Adding? Deleting?
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Right, Mac.

But what if the form that contains the pushbutton was opened by that other form, and the other form is now waiting on the form with the pushbutton.

You can interact with formcaller, and formreturn, back to the calling form.

But I don't know if attaching a form var to a waiting form allows you to interact directly.
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Well, I think with a bit more info we can narrow this down.

Also, if indeed the 'active' form was opened by 'fund_search_step2', and it is WAITing, I believe formcaller allows that second form to close the form WAITing on it.

Or, formreturn(True) (or False, depending on how you set up 'fund_search_step2') could be used to cause that waiting form to close.

Also, the only reason this should matter is if that other form (fund_search_step2) has its table(s) locked. Or a construct within the form (table/tcursor) has them open-editing/locked.

At least, I think so.
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Well, write the contents of that formnames array to a text file, then paste here in a message.

There's probably some little thing we are all crossing paths on.
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Tony M
 (Inactive)
Below will enumerate open forms, and write them to 'forms.txt' in the WORKING directory:

var
fNames array[] string
ts textstream
i longint
endvar
enumformnames(fNames)
ts.open("forms.txt","nw")
for i from 1 to fNames.size()
ts.writeline(fNames)
endfor
ts.close()
Copy and paste the contents of forms.txt into a message here, if you would. Then we'll all be talking apples.
 Posted 22 years ago
Comment Quote
About Tony M +Expand
Location= 
Joined=23 years ago   MB Posts=410   KB Comments=1  
Leo
Civilized Africa
WINDOW: 1. A Graphical frame that enclose data ie on a computer screen.
2. A Structural frame through which the computer is ejected once the operator irritation level exceeds a critical stage.
(The Hackers Dictionary)
Another Leo
_ _ ___________________ _ _
We are Micro$oft
You will be assimilated
Resistance is futile
 Posted 22 years ago
Comment Quote
About Leo +Expand
Location=Civilized Africa  
Joined=23 years ago   MB Posts=96  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1213A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #8868 Counter
4229
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2025 Prestwood IT Solutions.   [Security & Privacy]