Rolf,
I would suggest a different approach to this problem. Instead of hard coding a JPG file name in the report, put a field name in that same place. IOW, in the field expression, in the report designer, put the name of a field in a table or cursor. The cursor then needs to hold the name of the file. Sounds confusing?
If you want each record to print on a new page, you can add a group in the report designer on recno(), and set the group to start on new page.
Here is an example:
select idNum, getPictureFileName(idNum) from myfile
report form test preview
procedure getPictureFileName
lparameters lnIdNum
local lcReturn, ;
lcFileToFind, ;
lnFieldWidth
lnFieldWidth = 30
lcFileToFind = allTrim(Str(lnIdNum)) + '.JPG'
if !empty(sys(2000, lcFileToFind))
lcReturn = lcFileToFind
else
lcReturn = "dummy.jpg"
endif
return padr(lcReturn, lnFieldWidth)
endif
See FAQ #7862 for more on this approach.
HTH,
steve
>I will restate my problem and clarify:
>
>I am using VFP 6.0, not 5,0 as I said.
>
>I create a report and insert two fields, the first, a 'picture/ActiveX Bound Control',
>the second, the record id 'idnum'.
>
>The report designer require a filename, so I select 'MyPict.JPG', which is accepted.
>
>The names of the jpg files correspond to the record id.
>
>I then run this simple program, where consective reports show the correct
>record id, but the picture reamins the same, which is whatever picture
>happened to be in MyPict when I exited the report designer, saving the report.
>
>Use MyFile
>for n = 1 to 3
> bnum = idnum
> gcPic = AllTrim(Str(idnum)) + '.JPG'
> If !Empty(Sys(2000,gcPic))
> Copy File (gcPic) To MyPic.JPG
> Else
> Copy File DUMMY.JPG To Mypic.JPG
> Endif
> clear resources MyPic.jpg
> repo form test for idnum = bnum preview
> select MyFile
> locate for idnum = bnum
> skip
>next
>
>If this really is supposed to work, what is my error?
>
>Rolf
Steve Gibson