Discussion:
help with bookmark()
(too old to reply)
Ivan Benttini
2008-11-20 17:53:53 UTC
Permalink
Hi,
Help with bookmark() please!

In form #1 I navigate to a desired rowset, when find it,
I bookmark it.
Then open form #2 expecting to be a the selected rowset
done in form #1, instead I get an error:
Error: DATA TYPE mismatch expecting: BOOKMARK

IN form #1 when I click a PB I my code is:

form.bookmark=form.rowset.bookmark()
set proc to NABKFRAMED2.wfm additive
fChild=new NABKFRAMED2FORM()
fChild.ParentFORM=FORM
fChild.mdi=false
fChild.readmodal()

Now I open form #2, and I code:
form.rowset.goto(bookmark)

Hoping to go to the rowset seleting in form #1,
but instead I got this error above.
I hope someone understand my english.

Any help?

Thanks in advance,
Ivan
Bruce Beacham
2008-11-20 18:30:13 UTC
Permalink
Post by Ivan Benttini
form.bookmark=form.rowset.bookmark()
form.rowset.goto(bookmark)
1 The bookmark must be applied to the same rowset object. Where is
your code that assigns the first form's rowset _object_ as the rowset of
the fchild form?

2 "bookmark" as you have it there is just a variable. What is in that
variable? On the assumption you have dealt with 1 above, you need to add:

bookmark = form.parentForm.bookmark
form.rowset.goto(bookmark)



Bruce Beacham
Ivan Benttini
2008-11-20 19:16:50 UTC
Permalink
Hi Bruce,
Here is the code:

In form #1 I navigate to desired rowset, when find it,
I bookmark it.
Then open form #2 expecting to be a the selected rowset
done in form #1, instead I get an error:

Error: variable undefined: parentform

IN form #1 when I click a PB I code this:
function PUSHBUTTON1_onClick //go open another page
///////////////////form.bookmark=form.rowset.bookmark()
///////////////////?form.bookmark

bookmark=form.parentform.bookmark() //bruce's recomendation
form.rowset.goto(bookmark) //bruce's recomendation

when run I get the below error:
error: variable undefined: parentform

x=form.na1.rowset.fields["fname"].value
?"first name: ",x

set proc to NABKFRAMED2.wfm additive //open a new form as next page
fchild=new NABKFRAMED2FORM() //with the contents of the
fchild.parentFORM=FORM //MEMO field on the table NA.dbf
fchild.MDI=false
fchild.readMODAL()
return

Now in form #2, my code:

function form_onOpen
form.rowset.goto(bookmark)

// the lines below is a must for the MENU to work.
this.root.EDITUNDOMENU:=this.root.EDIT.UNDO
this.root.EDITCOPYMENU:=this.root.EDIT.COPY
this.root.EDITCUTMENU:=this.root.EDIT.CUT
this.root.EDITPASTEMENU:=this.root.EDIT.PASTE
return


Hoping to go to the rowset seleting in form #1,
but instead I got this error above: error: variable undefined: parentform
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Post by Ivan Benttini
form.bookmark=form.rowset.bookmark()
form.rowset.goto(bookmark)
1 The bookmark must be applied to the same rowset object. Where is your
code that assigns the first form's rowset _object_ as the rowset of the
fchild form?
2 "bookmark" as you have it there is just a variable. What is in that
bookmark = form.parentForm.bookmark
form.rowset.goto(bookmark)
Bruce Beacham
Geoff Wass [dBVIPS]
2008-11-23 06:25:39 UTC
Permalink
Post by Ivan Benttini
Hi Bruce,
In form #1 I navigate to desired rowset, when find it,
I bookmark it.
Then open form #2 expecting to be a the selected rowset
<snipped>


Ivan,

BOOKMARKs work only with the *same* rowset object from which they are
created. Rowset2 cannot use a bookmark from rowset1.

There are different ways to do what you want. One is to use a DATAMODREF
which allows you to have one datamodule shared between two or more FORMs
and/or REPORTs.

Another method is to use ROWSET2.findKey() or some other technique to
locate the row before you open the form or during the onOpen.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Ivan Benttini
2008-11-20 19:26:53 UTC
Permalink
///////////////////////////////// maybe this is more clear, I hope
///////////////////////////////////////////////////
//////////////////////////////// I understood what you asking.
///////////////////////////////////////////////////
code from form #1
function PUSHBUTTON1_onClick //go open another page
///////////////////form.bookmark=form.rowset.bookmark()
///////////////////?form.bookmark
bookmark=form.parentform.bookmark()
form.rowset.goto(bookmark)

///////////////////x=form.na1.rowset.fields["fname"].value
///////////////////?"first name: ",x
///////////////////form.rowset.goto(form.bookmark)

set proc to NABKFRAMED2.wfm additive //open a new form as next page
fchild=new NABKFRAMED2FORM() //with the contents of the
fchild.parentFORM=FORM //MEMO field on the table NA.dbf
fchild.MDI=false
fchild.readMODAL()
return


opening form #2
function form_onOpen

form.rowset.goto(bookmark)

// the lines below is a must for the MENU to work.
this.root.EDITUNDOMENU:=this.root.EDIT.UNDO
this.root.EDITCOPYMENU:=this.root.EDIT.COPY
this.root.EDITCUTMENU:=this.root.EDIT.CUT
this.root.EDITPASTEMENU:=this.root.EDIT.PASTE
return

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Post by Ivan Benttini
form.bookmark=form.rowset.bookmark()
form.rowset.goto(bookmark)
1 The bookmark must be applied to the same rowset object. Where is your
code that assigns the first form's rowset _object_ as the rowset of the
fchild form?
2 "bookmark" as you have it there is just a variable. What is in that
bookmark = form.parentForm.bookmark
form.rowset.goto(bookmark)
Bruce Beacham
Ivan Benttini
2008-11-20 21:13:50 UTC
Permalink
Greg, / Bruce
Thanks so much, your approach works just perfect.
In my readings about dBase, in addition to me, 2 others
guys would be proud of you fellows: Wayne Ratliff, and
Jeb Long, from the 80's. Today I learn a new way to replace
the old GOTO and the new BOOKMARK, with thanks to
you all.
Hope you all have a nice weekend.
Ivan
Post by Ivan Benttini
Hi,
Help with bookmark() please!
In form #1 I navigate to a desired rowset, when find it,
I bookmark it.
Then open form #2 expecting to be a the selected rowset
Error: DATA TYPE mismatch expecting: BOOKMARK
form.bookmark=form.rowset.bookmark()
set proc to NABKFRAMED2.wfm additive
fChild=new NABKFRAMED2FORM()
fChild.ParentFORM=FORM
fChild.mdi=false
fChild.readmodal()
form.rowset.goto(bookmark)
Hoping to go to the rowset seleting in form #1,
but instead I got this error above.
I hope someone understand my english.
Any help?
Bookmarks have some limitations as mentioned by Bruce, another limitation
is changing INDEX, if you change the index your bookmarks will be
destroyed.
You are better off using a unique id field in your rowset to accomplish
the same thing.
For the below example suppose you have a field called PrimaryID
(autoincrement) field, and that the desired rowset is assigned to the form
(form.rowset = form.yourRowset.rowset)
cPrimaryID = form.rowset.fields["primaryID"].value
set proc to NABKFRAMED2.wfm additive
fChild=new NABKFRAMED2FORM()
fChild.ParentFORM=FORM
fChild.rowset.indexName = "primaryID" // new line, primaryID is a unique
number for every record
fChild.rowset.setRange(cPimaryID) // new line
fChild.rowset.canNavigate = {||false} //new line
fChild.mdi=false
fChild.readmodal()
Greg Hill
Greg Hill
2008-11-21 01:16:07 UTC
Permalink
Post by Ivan Benttini
Greg, / Bruce
Thanks so much, your approach works just perfect.
In my readings about dBase, in addition to me, 2 others
guys would be proud of you fellows: Wayne Ratliff, and
Jeb Long, from the 80's. Today I learn a new way to replace
the old GOTO and the new BOOKMARK, with thanks to
you all.
Hope you all have a nice weekend.
Ivan
Thank for the success report. It helps to have someone like you on the
receiving end, you know how work things out.

Greg Hill
Greg Hill
2008-11-20 19:37:02 UTC
Permalink
Post by Ivan Benttini
Hi,
Help with bookmark() please!
In form #1 I navigate to a desired rowset, when find it,
I bookmark it.
Then open form #2 expecting to be a the selected rowset
Error: DATA TYPE mismatch expecting: BOOKMARK
form.bookmark=form.rowset.bookmark()
set proc to NABKFRAMED2.wfm additive
fChild=new NABKFRAMED2FORM()
fChild.ParentFORM=FORM
fChild.mdi=false
fChild.readmodal()
form.rowset.goto(bookmark)
Hoping to go to the rowset seleting in form #1,
but instead I got this error above.
I hope someone understand my english.
Any help?
Bookmarks have some limitations as mentioned by Bruce, another limitation is
changing INDEX, if you change the index your bookmarks will be destroyed.

You are better off using a unique id field in your rowset to accomplish the
same thing.
I would use the following approach:

For the below example suppose you have a field called PrimaryID
(autoincrement) field, and that the desired rowset is assigned to the form
(form.rowset = form.yourRowset.rowset)


cPrimaryID = form.rowset.fields["primaryID"].value

set proc to NABKFRAMED2.wfm additive
fChild=new NABKFRAMED2FORM()
fChild.ParentFORM=FORM
fChild.rowset.indexName = "primaryID" // new line, primaryID is a unique
number for every record
fChild.rowset.setRange(cPimaryID) // new line
fChild.rowset.canNavigate = {||false} //new line
fChild.mdi=false
fChild.readmodal()

Greg Hill
Loading...