Subject Re: Closing an image on a form
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 8 Apr 2021 10:46:08 +0200
Newsgroups dbase.getting-started

On 2021/04/07 22:34, royprice wrote:

> My inexperience is showing......
> I only have three image controls because I didn't even consider that only one would do the job.
>
> In retrospect what seems obvious now, wasn't before.
>
> So here I go again

Even the most experienced programmer had to start somewhere.  The name
of this newsgroup says it all.  Nobody expects participants to be
experienced.  The replies here are generally a bit more detailed than,
say, in the programming newsgroup. And remember, the only "silly"
question is the one you don't ask.

The example event handlers I posted earlier can be made less "messy" by
saving some objects to variables.  You can name variables virtually
anything you like (but avoid reserved words) but I find it helps to
start with a lowercase character denoting the type of the contents
followed by the name.  For example nFiles for a numeric value, cName for
a string, dStart for a date, oForm or oDmd for an object

   function IMAGEPHOTO01_onOpen()
      //This event handler ensures that an image is displayed when
      //the form opens.  You may need to add code to make sure that
      //the correct image is shown.
      oDmd = form.cactusaadatamodule1
      oMainRowsetFld =
form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]
      //Saving objects to variables reduces typing later
      if oMainRowsetFld = '01'
        this.dataSource = oDmd.photos01_dbf1.rowset.fields["photo"]
      elseif oMainRowsetFld = '02'
        this.dataSource = oDmd.photos02_dbf1.rowset.fields["photo"]
      elseif oMainRowsetFld = '03'
        this.dataSource = oDmd.photos03_dbf1.rowset.fields["photo"]
      endif
      return.


   function rowset_onNavigate(type, nRows)
      //This event handler ensures that the image displayed as the
      //user navigates the main table comes from the correct image table
      oForm = this.parent.parent.parent
      oDmd = this.parent.parent
      if this.fields['photoyesfile'].value = '01'
        //add code here to navigate to correct record in photos01_dbf1
        oForm.imagephoto01.datasource =
oDmd.photos01_dbf1.rowset.fields["photo"]
      elseif this.fields['photoyesfile'].value = '02'
       //add code here to navigate to correct record in photos02_dbf1
        oForm.imagephoto01.datasource =
oDmd.photos02_dbf1.rowset.fields["photo"]
      elseif this.fields['photoyesfile'].value = '03'
       //add code here to navigate to correct record in photos03_dbf1
        oForm.imagephoto01.datasource =
oDmd.photos03_dbf1.rowset.fields["photo"]
      endif
      return


Mervyn.