Subject Re: Form to Form
From Peter <phb2020@hotnail.com>
Date Fri, 12 May 2023 15:27:00 -0400
Newsgroups dbase.getting-started

Peter wrote:
I am away without my computer ( a treat to myself).so I canít test anything.
Some clarification for some your questions:
The pat_no field is 5 numbers. That is the field that is ultimately responsible as unique to select any choice, not last _name+first_name, although there is an index of patienttest.dbf that is upper(last_name+first_name) with spaces and trims as has been described many times, appropriately, in your books.
Even if user enters last_name into entryfield1 to determine order of grid, I have always wanted to use pat_no as unique field to define how later seeks are used. User has choice of entry as either last_name or pat_no, onLostFocus of entryfield1, index is selected for order in grid. After pushbutton_goto is clicked, I planned to use pat_no as the way to proceed to second form in order to edit.  
Maybe a bit wordy, but there you have it.
Iím a bit surprised that there isnít a best way to get pat_no from firm1 to form2. These 2 forms use the same dbf.
Peter



Mervyn Bick Wrote:

> On 2023/05/11 13:02, Mervyn Bick wrote:
>
> >  ¬† function PBGOTO_OnClick()
> >  ¬†¬†¬† //Save the pat_no value to a user-defined property of editpastest
> >  ¬†¬†¬† //in memory
> >  ¬†¬†¬† form.edit_pat_test.Goto = class::get_pat_no() //Discussed later.
> >  ¬†¬†¬† if form.edit_pat_test.goto <> null
> >  ¬†¬†¬†¬†¬† //Set the rowset pointer in editpastest
> >  ¬†¬†¬†¬†¬† //I assume the query name in editpattest is also patient1. If not,
> >  ¬†¬†¬†¬†¬† //use the correct query name.
> >  ¬†¬†¬†¬†¬† form.edit_pat_test.patient1.rowset.goto(form.edit_pat_test.goto)
> >  ¬†¬†¬†¬†¬† form.edit_pat_test.open()
> >  ¬†¬†¬† else
> >  ¬†¬†¬†¬†¬† msgbox('Invalid patient number or name')
> >  ¬†¬†¬† endif
> >  ¬†¬†¬† return
> >
> >
> >  ¬† function get_pat_no()
> >  ¬†¬†¬† //As the user can enter either the patient number or the patient
> >  ¬†¬†¬† //name you need some mechanism for making sure the user enters a
> >  ¬†¬†¬† //valid value.
> >  ¬†¬†¬† local nRet
> >  ¬†¬†¬† nRet = null // If a record is found this will be overwritten
> >
> >  ¬†¬†¬† // Code needed here to verify selection.
> >
> >  ¬†¬†¬† return nRet
>
> After a bit more thought, getting the pat_no required is better done
> before the user clicks on the GOTO pushbuton.
>
>
>    function PBGOTO_OnClick()
>      //The pat_no value has been saved to a user-defined property
>      //of editpastest   form.edit_pat_test.goto   in memory
>      //Set the rowset pointer in editpattest
>      //I assume the query name in editpattest is also patient1. If not,
>      //use the correct query name.
>      form.edit_pat_test.patient1.rowset.goto(form.edit_pat_test.goto)
>      form.edit_pat_test.open()
>      return
>
> As the user moves through the patient file use the rowset's onNavigate
> event handler to save the pat_no to form.edit_pat_test.goto  ready for
> the user to click the GOTO button.  The user can use the up and down
> arrow keys to move through the patient table displayed in a grid in
> which case a new pat_no will be saved each time a new record is
> selected.  If the user uses the mouse wheel to scroll the grid it will
> be necessary to click on a record to save the pat_no.
>
>      function rowset_onNavigate(type, nRows)
>        local cPatient,f
>        form.edit_pat_test.goto = this.fields['pat_no'].value
>        //Display the selected patient's name in a separate entryfield
>        //Don't overwrite the entryfield used for keyboard selection
>        f = form.patient1.rowset.fields //To save typing later
>        cPatient = f['pat_no'].value + ' --- '
>        cPatient += trim(f['lname'].value) + ', '
>        cpatient += trim(f['fname'].value)
>        form.entryfield2.value = cPatient
>        return
>
> To make sure form.edit_pat_test.goto has the value of the first patent
> when the form opens use the query's onOpen event handler.  If you don't
> do this clicking the GOTO button to open the edit form for the first
> patient will give an error.
>
>      function PATIENT1_onOpen()
>        form.edit_pat_test.goto = this.rowset.fields['pat_no'].value
>        return
>
> You are going to have to decide whether you want to open the the main
> form with the patients displayed in patient order or name order.
> Probably the name order would be the better choice.
>
> To allow the user to type either a pat_no or a last name into
> entryfield1 may mean some fancy footwork in entryfield1's onKey event
> handler.  Is your pat_no field numeric(5,0) or is it char(5)?
>
> We're heading into another 4hour power outage shortly so that's it for now.
>
> Mervyn.
>
>
>
>
>
>
>
>
>
>
>