Subject |
Form to Form |
From |
Peter <phb2020@hotmail.com> |
Date |
Tue, 09 May 2023 16:04:54 -0400 |
Newsgroups |
dbase.getting-started |
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
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
return
|
|