Subject |
Re: Form to Form |
From |
Peter <phb2020@hotmail.com> |
Date |
Wed, 10 May 2023 17:33:24 -0400 |
Newsgroups |
dbase.getting-started |
Unfortunately, this does not work.
First I get message that "form cannot be MDI".
Then the form.patient.rowset.fields["pat_no"] does not seem to work.
Here is what I put in:
function PBGOTO_onClick()
/* if isalpha(form.ENTRYFIELD1.value)
form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value+" -- "+;
TRIM(form.patient1.rowset.fields["lname"].value)+", " + ;
form.patient1.rowset.fields["fname"].value
else
form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value
endif
*/
form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value
mgoto = form.patient1.rowset.fields["pat_no"].value
set procedure to editpattest.wfm
oNewForm = new editpattestform()
oNewForm.mdi := false //true
//Custom Property of the new form
oNewform.mGoto = form.patient1.rowset.fields["pat_no"].value
oNewform.readmodal()
oNewform.release()
oNewform = null
close procedure editpattest.wfm
form.close()
return
function form_onOpen()
if type("form.mGoto") == "N"
form.query1.rowset.findkey(mGoto)
//This next line shows INCORRECT value of pat_no.
msgbox("Value of pat_no: " + form.query1.rowset.fields["pat_no"].value)
//This line shows error: Unrecognized command verb
form.query1.rowset.fields["pat_no"].value
else
msgbox("Type of mGoto: "+type("form.mGoto"))
endif
Ken Mayer Wrote:
> On 5/9/2023 1:04 PM, Peter wrote:
> > I am having trouble linking the data file from one for to a second form. In form1 there is a grid from which the user can choose a name (First name and Second Name) or ID# (a numeric field with length of 5).
> > Once a name has been highlighted, a pushbutton will take the user to a second form, form2, to edit all fields. Same data file in each. But I am having trouble using the ID# either as a parameter or a memory variable from form1 to add to sql statement so form2 can show all fields.
> > I had this problem solved a few weeks ago, but after messing around the sql won't work.
> > I am copying some code for your benefit.
> > Entryfield1 allows user to enter either ID# or part of Last Name. I use isalpha() to change index depending on whether entryfield1 starts with a letter or a number. That works to show ID# or name in selected order.
> >
> > I look forward to your help.
> > Peter
> >
> >
> > FROM FORM1 -- has GRID
> > function PBGOTO_onClick()
> > if isalpha(form.ENTRYFIELD1.value)
> > form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value+" -- "+;
> > TRIM(form.patient1.rowset.fields["lname"].value)+", " + ;
> > form.patient1.rowset.fields["fname"].value
> > else
> > form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value
> > endif
> > form.entryfield1.value = form.patient1.rowset.fields["pat_no"].value
> > mgoto = form.patient1.rowset.fields["pat_no"].value
> > DO editpattest.wfm with true,mgoto
>
> Okay, better:
>
> set procedure to editpattest.wfm
> oNewForm = new editpattestform()
> oNewForm.mdi := true
> // custom property of the new form:
> oNewForm.mGoto = form.patient1.rowset.fields["pat_no"].value
> oNewForm.readModal()
> oNewForm.release()
> oNewForm = null
> close procedure editpattest.wfm
>
>
> > form.close()
> > return
> >
> > BOOTSTRAP OF FORM2
> > parameter bModal, mgoto
> > local f
> > f = new EditPatTestForm()
> > if (bModal)
> > f.mdi = false // ensure not MDI
> > f.readModal()
> > else
> > f.open()
> > endif
> >
> > QUERY OF FORM2
> > this.DATABASE1 = new DATABASE(this)
> > with (this.DATABASE1)
> > left = 728.0
> > top = 11.0
> > width = 53.0
> > height = 37.0
> > databaseName = "MYTEST"
> > active = true
> > endwith
> >
> > this.QUERY1 = new QUERY(this)
> > with (this.QUERY1)
> > left = 812.0
> > top = 11.0
> > width = 39.0
> > height = 37.0
> > database = form.database1
> > databaseName = "MYTEST"
> > sql = "select * from patienttest" // where pat_no = mgoto" I tried this; does not work
> > indexName = "pat_no"
> > active = true
> > //this.rowset.fields["pat_no"].value = mgoto //I tried this; does not work
> > endwith
> >
> >
> > TEST OF Form_onOpen
> >
> > function form_onOpen()
> > /* d = new database()
> > d.databasename := "MyData"
> > d.active := true
> > patient1 = new query()
> > database := d
> > sql := "select * from patienttest"
> > active := true
> > rowset.indexname := "pat_no"
> > rowset.fields["pat_no"]=100 //a test of random "pat_no" does not work
> > */
> > msgbox("Param: "+mgoto) //This works: shows mgoto value
> > //form.query1.rowset.fields["pat_no"].value = mgoto //BUT this does not work
>
> Too much in the onOpen():
>
> if type( "form.mGoto" ) == "N"
> form.query1.rowset.findKey( mGoto ) // similar to seek
> ? "Value of some other field ...: "
> +form.query1.rowset.fields["fieldname"].value
> else
> ? "Type of mGoto: " + type( "form.mGoto" )
> endif
>
> Note that this is untested. The idea is to not pass the value as a
> parameter, but to create a custom property on the new form ... then you
> can reference it as "form.MyCustomPropertyName" ...
>
> Ken
>
>
>
> --
> *Ken Mayer*
> Ken's dBASE Page: http://www.goldenstag.net/dbase
> The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
> dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
> dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
> dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
> dBASE DOS to Windows Tutorial:
> http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm
>
|
|