Subject Re: Closing an image on a form
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 7 Apr 2021 22:30:30 +0200
Newsgroups dbase.getting-started

On 2021/04/07 15:12, Mervyn Bick wrote:

> I'm taking a break now to watch the rest of the ODI cricket match
> between Pakistan and South Africa but I'll give you some code tomorrow.
> Unless someone else does so first. :-)

What a waste of good computing time that turned out to be.  South Africa
played badly and was thoroughly beaten by Pakistan. :-(

In the following event handler for
form.cactusadatamodule1.cactusaa_dbf1.rowset

     this is form.cactusadatamodule1.cactusaa_dbf1.rowset
     this.parent is form.cactusadatamodule1.cactusaa_dbf1
     this.parent.parent is form.cactusadatamodule1
     this.parent.parent.parent is form

With your form open in the designer select the main table's rowset in
the dropdown list.  Select the Events tab and then select the onNavigate
event.  Click on the "spanner" button to create the skeleton for the
event handler and then use the code in one of the following event
handlers.  Although I've been over it fairly carefully the code is
untested so it may have problems.  If you can't sort them out yourself
post the error messages.

With three image controls on the form

    function rowset_onNavigate(type, nRows)
       if this.fields['photoyesfile'].value = '01'
         //add code here to navigate to correct record in photos01_dbf1
         this.parent.parent.parent.imagephoto01.datasource =
this.parent.parent.photos01_dbf1.rowset.fields["photo"]
         this.parent.parent.parent.imagephoto02.datasource = []
         this.parent.parent.parent.imagephoto03.datasource = []
       elseif this.fields['photoyesfile'].value = '02'
          //add code here to navigate to correct record in photos02_dbf1
         this.parent.parent.parent.imagephoto02.datasource =
this.parent.parent.photos02_dbf1.rowset.fields["photo"]
         this.parent.parent.parent.imagephoto01.datasource = []
         this.parent.parent.parent.imagephoto03.datasource = []
       elseif this.fields['photoyesfile'].value = '03'
         //add code here to navigate to correct record in photos03_dbf1
         this.parent.parent.parent.imagephoto03.datasource =
this.parent.parent.photos03_dbf1.rowset.fields["photo"]
         this.parent.parent.parent.imagephoto01.datasource = []
         this.parent.parent.parent.imagephoto02.datasource = []
       endif
       return

With one image control on the form

    function rowset_onNavigate(type, nRows)
       if this.fields['photoyesfile'].value = '01'
         //add code here to navigate to correct record in photos01_dbf1
         this.parent.parent.parent.imagephoto01.datasource =
this.parent.parent.photos01_dbf1.rowset.fields["photo"]
       elseif this.fields['photoyesfile'].value = '02'
        //add code here to navigate to correct record in photos02_dbf1
         this.parent.parent.parent.imagephoto01.datasource =
this.parent.parent.photos02_dbf1.rowset.fields["photo"]
       elseif this.fields['photoyesfile'].value = '03'
        //add code here to navigate to correct record in photos03_dbf1
         this.parent.parent.parent.imagephoto01.datasource =
this.parent.parent.photos03_dbf1.rowset.fields["photo"]
       endif
       return



Mervyn.