Subject Re: Form to Form
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 13 May 2023 11:49:43 +0200
Newsgroups dbase.getting-started

On 2023/05/12 21:27, Peter wrote:
> Peter wrote:
> I am away without my computer ( a treat to myself).so I can抰 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抦 a bit surprised that there isn抰 a best way to get pat_no from firm1 to form2. These 2 forms use the same dbf.
> Peter

I'm regularly without my computer due to $%£@£# load shedding of up to 4
hours at a time. :-(  I've got just over an hour before the lights go
out again for 2 hours.

As pat_no is unique for each patient it is ideal for ensuring that
"child" forms that are opened once a patient has been selected use the
correct record.  It is, however, not such a good idea to use it for
selecting the record for a patient.  Unless the user can remember the
patient numbers (which may or may not be consecutive) for, say, "Smith,
John", "Smith, Jane", "Smith, Jennifer" and "Smith, James" it is far
easier to enter the surname character by character.  As each character
is entered the rowpointer will get closer and closer to the required
patient.  Either type in enough characters so that the rowpointer is on
the required record or use the mouse to make the final selection once
you get close enough.

I suggest creating using the following index expression to create the
index fullname.  lower(lname)-lower(fname)   Using lower() makes the
search case-insensitive and -, rather than +, moves all trailing spaces
to the end thereby maintaining a constant length for the index values.
The index values will be something like

smithjames
smithjane
smithjennifer
smithjohn

Entering smithje would take you direct to her record.  Her pat_no is in
the record so you can use that to select the appropriate record in any
"child" form you open.

If the actual field type is numeric(5,0) you need to create an index,
say cPat_no, on pat_no using the index expression  str(pat_no,5)

If the field type is character, even if it only contains digits, you
need to create an index, again say cPat_no, using the index expression
right(space(5)+trim(pat_no),5)

Unless you right justify the character values your rowset will order
something like

1
11
111
2
21
3

As an aside, using trim() in an index expression is normally a no-no as
the index value for each record must be the same length.  In this case
right() is used to ensure that each index value is 5 characters long.

Instead of using the entryfield's onLostFocus event handler use its
onKey event handler.

Time's up for now.  Keep tuned in for the next exciting episode. :-)

Mervyn.