I found a way to mimic this use in a form.  I have a 2-table form, where
the master table is actually a view based on the slave table (so basically
the same table appears twice on the form).  The view is the first and last
names concatenated, and also contains the StudentID field.  The table
itself has all the editable fields.

The view has the names located in a DBGrid.  When you click on a name,
the fields all fill in in the editable fields for the Students table.  Here's where
you make and save your changes.  Unfortunately, there isn't a "walkmenu"
ability in that DBGrid so it wouldn't work if you had to scroll thru thousands
of names!  And I haven't tried this in a recent version, but back when I designed
it I could not refresh the DBGrid to show if I added a new student in the table
while within the form, so my "add" button exits the form to add, then comes
back in.

Karen



> I want to use a combo box on a form to select the
> record to be viewed or
> edited on the same form.

There isn't anyway to change the underlying record set
from inside an R:Base form.  You need to close the
form and reopen it with a new WHERE clause.

If you're willing to close and reopen the form, you
can do what you want pretty simply.  Your code will
look something like:

SET VAR vLookupID INT = NULL
WHILE 1 = 1 THEN
 EDIT USING MyForm WHERE IDColumn = .vLookupID
 IF vLookupID IS NULL THEN
   BREAK -- From WHILE loop
 ENDIF
ENDWHILE

Now, in your form place your combo box and right next
to it a button labelled "Go" or "Edit Now" or
whatever.  The code in this EEP should include

SET VAR vLookupID = .vComboBoxVariable
CLOSEWINDOW

Now, when the user clicks on the Go button, the form
will close, the WHILE loop will loop, and the form
will reappear with the new record.  Voila!

When the user closes the form without hitting the Go
button, the variable vLookupID will be NULL and the
WHILE loop will exit.

(Instead of using the button, you could put your code
in the OnClick EEP of the combo box, but the user
might fire it accidentally while just looking through
the list of names).

To do what you want to do WITHOUT closing and
reopening the form, you would have to edit all records
in the table and then write an EEP to move the first
record and do a NEXT until it found the right record
-- guaranteed to be SLOW unless you can strictly limit
the number of records in the table.
--


Reply via email to