Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pictures in reports problem
Message
De
08/03/2002 10:27:55
 
 
À
08/03/2002 05:54:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00627712
Message ID:
00630200
Vues:
17
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  && add a where clause to narrow your selection down
report form test preview


procedure getPictureFileName
lparameters lnIdNum
* this is a simplified example
* this assumes that all pictures are in the current directory

	local   lcReturn, ;
		lcFileToFind, ;
		lnFieldWidth
		
	lnFieldWidth = 30  && it is important to set a field width wide enough
	                   && to cover all possible file names, or you will
	                   && have truncation problems in your cursor

	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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform