if not file('fish_demo.dbf') copy table :dbasesamples:fish to fish_demo alter table fish_demo add photoyesfile char(2) use fish_demo scan replace photoyesfile with '0'+ltrim(str(mod(id,3)+1)) endscan use endif ** END HEADER -- do not remove this line // // Generated on 2021-04-10 // parameter bModal local f f = new three_imagesForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class three_imagesForm of FORM with (this) onOpen = class::FORM_ONOPEN height = 21.0909 left = -1.2857 top = 0.7273 width = 106.8571 text = "" endwith this.DBASESAMPLES1 = new DATABASE(this) with (this.DBASESAMPLES1) left = 13.0 width = 11.0 height = 1.0 databaseName = "DBASESAMPLES" active = true endwith this.FISH1 = new QUERY(this) with (this.FISH1) left = 4.0 width = 3.0 height = 1.0 database = form.dbasesamples1 sql = "select * from FISH.DBF" active = true endwith this.FISH2 = new QUERY(this) with (this.FISH2) left = 30.0 width = 3.0 height = 1.0 database = form.dbasesamples1 sql = "select * from FISH.DBF" active = true endwith this.FISH_DEMO1 = new QUERY(this) with (this.FISH_DEMO1) left = 45.0 width = 8.0 height = 1.0 sql = 'select * from "fish_demo.DBF"' active = true endwith with (this.FISH_DEMO1.rowset) onNavigate = class::ROWSET_ONNAVIGATE endwith this.FISH3 = new QUERY(this) with (this.FISH3) left = 39.0 width = 3.0 height = 1.0 database = form.dbasesamples1 sql = "select * from FISH.DBF" active = true endwith this.GRID1 = new GRID(this) with (this.GRID1) dataLink = form.fish_demo1.rowset height = 12.4545 left = 2.0 top = 3.1364 width = 69.8571 endwith this.IMAGE1 = new IMAGE(this) with (this.IMAGE1) height = 4.8182 left = 80.2857 top = 2.6364 width = 21.4286 dataSource = form.fish1.rowset.fields["fish image"] endwith this.IMAGE2 = new IMAGE(this) with (this.IMAGE2) height = 4.8182 left = 80.2857 top = 8.3636 width = 21.4286 dataSource = form.fish2.rowset.fields["fish image"] endwith this.IMAGE3 = new IMAGE(this) with (this.IMAGE3) height = 4.8182 left = 80.2857 top = 14.7273 width = 21.4286 dataSource = form.fish3.rowset.fields["fish image"] endwith this.rowset = this.fish1.rowset function form_onOpen() //Only one image table has the correct image so we need //to null the datasource property for two of the image controls mphoto = form.fish_demo1.rowset.fields["photoyesfile"].value If mPhoto='01' form.IMAGE2.dataSource = [] form.IMAGE3.datasource = [] elseif mPhoto='02' form.IMAGE1.dataSource = [] form.IMAGE3.datasource = [] elseif mPhoto='03' form.IMAGE1.dataSource = [] form.IMAGE2.datasource = [] endif return function rowset_onNavigate() if this.fields['photoyesfile'].value = '01' //Go to the correct record in the image file. //You will need to use the correct field names. // If the fields are character then // this.parent.parent.fish1.rowset.applyLocate( "id = '" + this.fields['id'].value +"'" ) this.parent.parent.fish1.rowset.applyLocate( "id = " + this.fields['id'].value ) //Set the datasource property of the image control to use this.parent.parent.image1.datasource = this.parent.parent.fish1.rowset.fields["fish image"] //Null the datasource property for each of the other image controls this.parent.parent.image2.datasource = [] //note: no space between the square brackets this.parent.parent.image3.datasource = [] elseif this.fields['photoyesfile'].value = '02' this.parent.parent.fish2.rowset.applyLocate( "id = " + this.fields['id'].value ) this.parent.parent.image2.datasource = this.parent.parent.fish2.rowset.fields["fish image"] this.parent.parent.image1.datasource = [] this.parent.parent.image3.datasource = [] elseif this.fields['photoyesfile'].value = '03' this.parent.parent.fish3.rowset.applyLocate( "id = " + this.fields['id'].value ) this.parent.parent.image3.datasource = this.parent.parent.fish3.rowset.fields["fish image"] this.parent.parent.image1.datasource = [] this.parent.parent.image2.datasource = [] endif return endclass