Form synchronization

|
EnigmaVariation
|
Please excuse me for asking something as basic as this but having read MP‘s book (albeit for Pdox 5 Win whilst I have Pdox 9) & looking through the Corel Pdox9 ObjectPAL Reference Guide, I have continued to fail to synchronize 2 forms!!!
The details (all forma & tables use the alias "Books")
My Books database (that includes "What Every Pdox5 for Windows Programmer...") has, for this request, 2 tables & 2 forms
Frm1 "Books_Main" with table frame to "Books_main.db" has as one of its fields "illus" type A1 with picture values of "Y""N" or blank (to cover old imported records). This is to give a value to "Is the book illustrated"
On the mouseClick method of this field is the code to open Frm2 "Books_graphics" that has a table frame to the table "Book_graphic.db" (a table giving data wrt the illustrations. This works except that I want the ‘open‘ to be conditional on the field value "Y" only but I have not suceeded on properly coding the if statement.
The key of Tbl1 is "AutoInc" (Type +), Tbl2 is joined by Field "AutoLink" Type I Tbl1 is included in both data models, Frm2 displaying the book title for reference.
I then need Frm2 to be synchronized and return control from the already defined & operational Push Button. For this I have tried the code from the Corel manual (Page 198) where it uses a "SetFocus" method. THis method also shows in MP‘s book in an Object Explorer screen shot . However, there is no pre-defined SetFocus method visible in the tableframe so I tried to define a new method "SetFocus": the programme will not permit me to create this. My forms remain unsynchronized!
(I could not find how to copy/paste the code snippets here). It works using Ctrl C/V but not right mouse button
method mouseClick(var eventInfo MouseEvent) var strFormName1 string strFormName2 string fld1 string fHandle form endVar
strFormName2 = ":books:Books_graphics.fsl" strFormName1 = ":books:books_main.fsl" fld1 = "illus"
;if fld1 = "Y" then
if NOT fHandle.attach(strFormName2) then fHandle.open(strFormName2,winStyleDefault) endIf
; if Not fHandle.strFormName1.locate("AutoLink",strFormName2)then ; fHandle.strFormName2.edit() ; fHandle.strFormName2.insertRecord() ; fHandle.strFormName2 = strFormName2.value ;else dodefault
;endIf
endMethod
Code in Frm2
method setFocus(var eventInfo Event)
var f Form ;Declare a form variable. tc TCursor ;Declare a TCursor variable. endVar
if f.attach(":Books:Books_Main") then ;Attach to other form. f.dmAttach(tc, ":Books:Books_Main.db") ;Attach tc to a table in the dmResync(":Books:Books_Main.db", tc) ;data model of the other form. ;Then sync the two forms. endIf endMethod
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18390, 14 replies
Thread Started 2/1/2021 7:50:20 AM
View Counter=126
Last Reply Posted 2/18/2021 7:25:02 AM)
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
I'll start with a couple of simple things, and work up from there
first.. copy/paste.. no different than anywhere else.. highlight the code, Edit/Copy or Ctrl-C, come to this thread and Edit/Paste or Ctrl-V
your table.. AutoInc is very bad.. if your table gets damaged, and the autoinc is lost, you can have a huge, unrecoverable mess on your hands.. a roll-your-own "next number" process is a little bit more trouble to start, but please look into it, for the safety of your data
your code.. in the mouse click, something like this
if illus = "Y" then
myform.open("my graphics form")
myform.wait()
myform.close()
endif
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 69 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18391 (Level 2)
and Parent is 18390
Reply Posted 2/1/2021 8:58:55 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
"Steve, Your code has the same effects that my code has; the form opens when the if statement is commented out but not with the if statement in place. I've checked the table to ensure that the value is "Y & not "y" (table is set to automatically capitalise).
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18392 (Level 1.1)
Reply to 18391
and Parent is 18390
Thread Started 2/1/2021 10:09:09 AM
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 69 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18393 (Level 3)
and Parent is 18390
Reply Posted 2/1/2021 10:19:32 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
method mouseClick(var eventInfo MouseEvent) var fld1 string myform form endVar
fld1 = "illus"
if fld1 = "Y" then myform.open(":books:Books_graphics.fsl")
myform.wait()
myform.close()
endIf
endMethod
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18395 (Level 1.1)
Reply to 18393
and Parent is 18390
Thread Started 2/1/2021 10:26:42 AM
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
and the context.. are you typing in the Y and not posting the record?
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 69 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18394 (Level 4)
and Parent is 18390
Reply Posted 2/1/2021 10:20:13 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
...for the tests the value "Y" is already posted, however, to be optimum it should open the graphics form during the creation of a new book record, The record could be posted prior to opening the graphics form, this would seem to be necessary for using a tCursor. The graphics form push button posts a new record prior to returning to the main form.
method pushButton(var eventInfo Event) var fHandle Form ;// tmp handle to current form strRetVal String ;// tmp handle to returned value endVar
fHandle.attach()
;// Check record status and the touched property to see if the record ;// needs to be posted ;// if active.recordStatus("New") OR active.recordStatus("Modified") OR (fHandle.touched = TRUE) then
;// Check with user before posting changes ;// strRetVal = msgQuestion("Saving Changes", "Are you sure you wish to save these changes?")
switch
;// Save the changes ;// case strRetVal = "Yes": if NOT active.unlockRecord() then msgStop("Attempt to post your changes failed", "Please check to make sure your entries are valid and try again.") return endIf
;// Abort the cancel so user can finish editing record ;// case strRetVal = "No": return
endSwitch endIf
;// If we get this far, return to the calling form ;// formReturn(TRUE)
endMethod
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18396 (Level 1.1)
Reply to 18394
and Parent is 18390
Thread Started 2/1/2021 10:36:13 AM
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
in your code, fld1 is a string, it's not the actual field, so you're comparing the value of the string, not comparing to the value in the field
get rid of the string stuff.. if "illus" is the name of the field, then
if "illus" = "Y"
will work
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 69 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18397 (Level 5)
and Parent is 18390
Reply Posted 2/1/2021 10:42:22 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
string stuff blown away, code as definedm still does not work. Have double checked the fiels name.
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18399 (Level 1.1)
Reply to 18397
and Parent is 18390
Thread Started 2/1/2021 11:07:58 AM
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
now you have me doing it, too.. correction
if illus = "Y"
it's an object, not a string.. no quotes
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 69 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18398 (Level 6)
and Parent is 18390
Reply Posted 2/1/2021 11:01:14 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18400 (Level 1.1)
Reply to 18398
and Parent is 18390
Thread Started 2/1/2021 11:11:42 AM
|
|
|
Location=Gomer, -- FR
|
|
 |
 |
|
EnigmaVariation
|
Thank you very much for your help & patience for what turned out to be absurdly simple !
Perhaps tomorrow you can help me resolve the sync problem, the fundamental; of this post. I'm sure this will be equally straightforward.
|
Posted 69 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18401 (Level 2.1)
Reply to 18400
and Parent is 18390
Thread Started 2/1/2021 3:44:44 PM
|
|
|
Location=Gomer, -- FR
|
|
| |
|
Moderator |
|
Steven.G
|
potential other concepts.. depends on your structure, the table frame, etc.
form2.open()
form2.table.locate("linkedField", form1.linkedField)
form2.wait()
-or-
form2.open()
form2.table.switchindex("linkedField")
form2.table.setrange(form1.linkedField)
form2.wait()
-or-
in this, or other contexts, you can seed form2 with text fields (hidden or not) with external values, and use those text field values for searches, filters, displays, etc.
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 68 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18402 (Level 7)
and Parent is 18390
Reply Posted 2/2/2021 6:58:09 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
 |
|
EnigmaVariation
|
Finally I have (with your help) got to the bottom of my initial problem. You advised me that using an AutoInc field as my key could lead to problems if I ever needed to rebuild my table: the comment was mentally noted.
I had always (incorrectly it now seems) considered that an AutoInc field was just a long integer with some built-in code to increment maxValue by 1 and that therefore the result was a 'fixed' datum.
To try to resolve the sync problem I decided to return to basics and sync a "Single Record" form in the "Books" database with the main form that displays a table view of the parent table. The sync routine failed on this.
I then tried on another, similarly constructed Equine database, The reSync worked as described in MP's book & your posts.
I then copied/pasted the code into the relevant "Books" form, made the necessary reference changes and got an error message (unfortunately I did not record this - one that I had never seen before).
I came to the conclusion that the reSync problems that I had experienced were down to the AutoInc field.
I rebuilt the database replacing the AutoInc key with a long integer key with corresponding numerical values.
It now works !!
During this process I copied the main table using Pdox utility and found that indeed the autoInc values were reset (I normally copy using File Manager so get an unaltered dataset). I also did a table rebuild with the same result.
So what is the value of the AutoInc facility as there is already a record number that changes?
END RESULT, problem solved and a warning not to use AutoInc but I still have to build in a counter to my key, long-integer field.
|
Posted 52 days ago (Thread Starter)
|
|
About EnigmaVariation |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18423 (Level 1.1)
Reply to 18402
and Parent is 18390
Thread Started 2/18/2021 3:36:18 AM
|
|
|
Location=Gomer, -- FR
|
|
| |
Most Recent Post
|
Moderator |
|
Steven.G
|
good to know.. thanks.. making your own "next number" process is a different way to look at your app, but it's very flexible.. and it doesn't break as easily as an AutoInc
Steven Green Senior Software Engineer Paradox Support Specialist DOS/WIN
Prestwood IT Solutions 8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610 Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
|
Posted 52 days ago
|
|
About Steven.G |
|
Approved member.
Member subscribes to this thread with a verified email.
Post ID #18424 (Level 8)
and Parent is 18390
Reply Posted 2/18/2021 7:23:17 AM
|
|
|
Location=Myrtle Beach, SC USA
|
|
Thread #18390 Counter |
126 |
Since 2/1/2021
|
|
|