Alpha Video Training
Results 1 to 3 of 3

Thread: Display a photo from a file in a report

  1. #1
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    384

    Default Display a photo from a file in a report

    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...
    Attached Files Attached Files
    Last edited by compuaid; 11-07-2011 at 03:59 PM. Reason: Clean up typos
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  2. #2
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    384

    Default Re: Display a photo from a file in a report

    I've fixed the issue. The problem was using the Parentform: modifier in front of my object references. Apparently on reports you don't need this to identify the top level as the Detail->OnRecord event is already pointing to the report top level. Anyway, the above code works flawlessly now once I removed all references to ParentForm.

    Thanks!
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  3. #3
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    384

    Default Re: Display a photo from a file in a report

    Just in case some else needs to use code that displays a photo from a file on a report that is tied to a specific field value on the report, here's the working code using the Topparent qualifier to make it relative to the specific report:


    '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 = topparent: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
    topparent:Control_Bitmap1.Bitmap.Filename = filearray[1].name
    topparent:Control_Bitmap1.object.visible = .t.
    else
    ' Don't display the bimap control if no photo is available
    topparent:Control_Bitmap1.object.visible = .f.
    end if
    Last edited by compuaid; 11-07-2011 at 04:24 PM.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

Similar Threads

  1. display image reference file images in a pdf report for web application
    By lemandras in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 03-24-2011, 12:15 PM
  2. Printing photo from file on pdf report
    By Pat Bremkamp in forum Application Server Version 9 - Web/Browser Applications
    Replies: 18
    Last Post: 07-15-2009, 06:21 PM
  3. Cannot display computed “Image File Reference” in report
    By harrison4411 in forum Alpha Five Version 9 - Desktop Applications
    Replies: 26
    Last Post: 04-21-2009, 12:02 AM
  4. Text file display
    By Mike Vance in forum Alpha Five Version 6
    Replies: 11
    Last Post: 05-06-2005, 11:17 PM
  5. image reference--poor photo display quality
    By VA Carlson in forum Alpha Five Version 6
    Replies: 0
    Last Post: 03-29-2005, 07:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •