I'm using Microsoft SQL Server so Image File Reference fields aren't an option to me. In my forms I've written an Xbasic routine that takes the unique property identifier from the current record and appends the directory path and uses the FileFind.Getfile command to locate all matching images for that property that are located in a separate subdirectory. The photos display perfectly on my form and I can even scroll through them. I placed a bitmap control on my report and copied the same code to my Details->OnRecord event limiting it to the first picture for the record (I only want one picture to display per record) but I can't reference the Bitmap Control from Xbasic to assign the new file name. When I run the debugger it shows that Parentform::Map_No.value (or any other control I attempt to reference on the report) is invalid. I've looked through the forums and I've not seen any solutions to using external .jpg files with desktop reports and SQL Server as the data source. Any assistance would be greatly appreciated!
Here's the code from my Report->Sections->Detail->OnRecord event.
'Date Created: 28-Oct-2011 08:20:21 PM
'Last Updated: 31-Oct-2011 08:54:11 AM
'Created By : Administrator
'Updated By : Administrator
DIM currentmap AS c
DIM files AS c
DIM shared filearray[1000] as p
' Clear the file array before using it on each record
filearray.clear()
' Get the map number from the Map_No textbox on the current record
currentmap = parentform:Map_no.value
'Set the file path
path = "\\developer\c$\Inetpub\ftproot\bcpva\Photos"
'Now look in the photos directory to see if any photos match the current Map_No
files = filefind.get(path+chr(92)+alltrim(currentmap)+"*.jpg",4096,"PN")
'Fill the filearray with a list of all matching photos
filearray.initialize_properties("name",files)
'Check to see if there are any matching photos and if so display the first one
if filearray.first_empty()>1 then
' check for multiple photos and only show the first one for now
parentform:Control_Bitmap1.Bitmap.Filename = filearray[1].name
parentform:control_Bitmap1.object.visible = .t.
else
' Don't display the bimap control if no photo is available
parentform:control_Bitmap1.object.visible = .f.
end if
Thanks...
Here's the code from my Report->Sections->Detail->OnRecord event.
'Date Created: 28-Oct-2011 08:20:21 PM
'Last Updated: 31-Oct-2011 08:54:11 AM
'Created By : Administrator
'Updated By : Administrator
DIM currentmap AS c
DIM files AS c
DIM shared filearray[1000] as p
' Clear the file array before using it on each record
filearray.clear()
' Get the map number from the Map_No textbox on the current record
currentmap = parentform:Map_no.value
'Set the file path
path = "\\developer\c$\Inetpub\ftproot\bcpva\Photos"
'Now look in the photos directory to see if any photos match the current Map_No
files = filefind.get(path+chr(92)+alltrim(currentmap)+"*.jpg",4096,"PN")
'Fill the filearray with a list of all matching photos
filearray.initialize_properties("name",files)
'Check to see if there are any matching photos and if so display the first one
if filearray.first_empty()>1 then
' check for multiple photos and only show the first one for now
parentform:Control_Bitmap1.Bitmap.Filename = filearray[1].name
parentform:control_Bitmap1.object.visible = .t.
else
' Don't display the bimap control if no photo is available
parentform:control_Bitmap1.object.visible = .f.
end if
Thanks...
Comment