Need help with jpg.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Denburt
    Recognized Expert Top Contributor
    • Mar 2007
    • 1356

    #16
    Me!Photo is the field we are parsing.

    Code:
    Private Sub Form_Current()
    Dim inInt As Integer
    Dim strPhoto As String
    inInt = InStr(Me!Photo, "#")
    If inInt > 0 Then
        strPhoto = Mid(Me!Photo, inInt + 1, Len(Me!Photo) - inInt - 1)
        Me!Image42.Picture = strPhoto
    else
    If Not IsNull(Me!Photo) And Len(Me!Photo) > 0 Then
        Me!Image42.Picture = Me!Photo
    End If
    end if
    End Sub

    Comment

    • robertoathome
      New Member
      • Mar 2007
      • 20

      #17
      Ahh, fantastic! It' working great now. Thanks for your time and I hope someday, somehow to return the favor. If you ever need furniture design or cad drawing don't hesitate to let me know.
      Thanks!

      Comment

      • Denburt
        Recognized Expert Top Contributor
        • Mar 2007
        • 1356

        #18
        Originally posted by robertoathome
        Ahh, fantastic! It' working great now. Thanks for your time and I hope someday, somehow to return the favor. If you ever need furniture design or cad drawing don't hesitate to let me know.
        Thanks!
        Great glad it is working for you now.

        Thanks for the offer and if you ever need a quick way of pulling info out of your cad drawings let me know as well, i'll be here.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #19
          Originally posted by robertoathome
          OK, something is working but not all.

          1) I'm assuming I need to use the first type of image holder, not the unbound or bound OLE object.
          2) when I run the code I get an error that says"

          "run-time error '2220':
          Microsoft access can't open the file 'T:\SHARED FILES\Administr ation\Masters and Molds Photos\040F-6F222032-TL.JPG#T:\SHARE D FILES\Administr ation\Masters and Molds Photos\040F-6F222032-TL.JPG#.

          Basically it dubles the link I have in the table1 and adds a ' # ' after it.
          If I go to debud I get the following highlighted
          ' Image42.Picture = Photo'

          Here's the code I used:

          Private Sub Form_Current()
          If Not IsNull(Photo) And Len(Photo) > 0 Then
          Image42.Picture = Photo
          End If
          End Sub

          THANKS!
          The '#' you are seeing is part of the Hyperlink Address which may consist of up to 4 parts separated by the number ('#') sign as in: displaytext#add ress#subaddress #screentip. You are getting doubles because you are both navigating to the Hyperlink Address and dynamicallly loading the images at the same time. If Hyperlinks are giving you trouble, you can dynamically load graphic Images into an Image Control at run time in the Current() Event of your Form.

          Comment

          • AKdlm
            New Member
            • Oct 2008
            • 7

            #20
            I know this thread is older, but my problem sounds very similar. I have a table that has a hyperlink field. I have one of my forms set up with a command button that is inserting hyperlinks into a textbox, which is then being stored into the previously mentioned table. This is all working just fine. The problem is with the report in which I want to display the images. I have a search command set up to pull a report with the corresponding images of that particular record number. It is pulling the report fine, except for the images. The error I get is Run-time error 2220 "Quality Feedback System can't open the file '#C:\documents and settings\test2. jpg#'. It is automatically adding they # before nad after the file path. This occurs no matter what I do. If I tell the report to pull the file path from just a text field (not a hyperlink field) the image displays just fine.

            To correct this I tried putting an After Update Event, in my form that stores the hyperlink, to copy the text to a textbox and then store that in the table instead. The probelm is that it is storing the correct path, but it is storing it all as text, even the # before and after the file path.

            I have this in the Details On Format Event of the report:

            Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
            Me!ImageFrame1. Picture = Me![ImageFilePath1]
            End Sub

            And it pulls from the table just fine, but the table is storing the hyperlink (which is adding the #'s and the beggining and end) or it is storing the After Update textbox with #'s as well.

            ImageFrame1 is on the report and ImageFilePath1 is the name of the field in the table. They each have a 1 because there is a total of 4 possible images on each report. But once I figure it out with 1, it should be easy to apply it to all 4.

            This has been driving me crazy!! Can anyone help with my report?

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #21
              Originally posted by AKdlm
              I know this thread is older, but my problem sounds very similar. I have a table that has a hyperlink field. I have one of my forms set up with a command button that is inserting hyperlinks into a textbox, which is then being stored into the previously mentioned table. This is all working just fine. The problem is with the report in which I want to display the images. I have a search command set up to pull a report with the corresponding images of that particular record number. It is pulling the report fine, except for the images. The error I get is Run-time error 2220 "Quality Feedback System can't open the file '#C:\documents and settings\test2. jpg#'. It is automatically adding they # before nad after the file path. This occurs no matter what I do. If I tell the report to pull the file path from just a text field (not a hyperlink field) the image displays just fine.

              To correct this I tried putting an After Update Event, in my form that stores the hyperlink, to copy the text to a textbox and then store that in the table instead. The probelm is that it is storing the correct path, but it is storing it all as text, even the # before and after the file path.

              I have this in the Details On Format Event of the report:

              Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
              Me!ImageFrame1. Picture = Me![ImageFilePath1]
              End Sub

              And it pulls from the table just fine, but the table is storing the hyperlink (which is adding the #'s and the beggining and end) or it is storing the After Update textbox with #'s as well.

              ImageFrame1 is on the report and ImageFilePath1 is the name of the field in the table. They each have a 1 because there is a total of 4 possible images on each report. But once I figure it out with 1, it should be easy to apply it to all 4.

              This has been driving me crazy!! Can anyone help with my report?
              Try:
              Code:
              Me!ImageFrame1.Picture = Replace(Me![ImageFilePath1], "#", "")

              Comment

              • AKdlm
                New Member
                • Oct 2008
                • 7

                #22
                Thanks for the help thus far.

                Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
                Me!ImageFrame1. Picture = Replace(Me![ImageFilePath1], "#", "")
                End Sub

                I put this in the Format Event of the Details section of the report, replacing what I had. I now get the error "Compile error: Sub or Function not defined". It highlights the first line in yellow and the word replace in blue. Any ideas? Does it matter that my company is still using Access 97? (probably should've mentioned that, sorry).

                Can we fix the problem at the source in the form? Instead of having a textbox = to exactly what the hyperlink field shows (which would include the #'s at both ends), can you have it equal to the hyperlink field minus the far left and far right characters or something?

                Maybe that wouldn't work at all and we should just stay in the report. Thanks again for the help.

                Comment

                • AKdlm
                  New Member
                  • Oct 2008
                  • 7

                  #23
                  So I converted the database to 2007 to test this out just for kicks, and the replace statement you suggested works amazingly. I can't get it to work for multiple images, and now the insert hyperlink is adding a double file path in 2007 - meaning if the path is C:\pictures\ima ge it is adding it as C:\pictures\ima geC:\pictures\i mage so now the report won't pull up any new entries I make. This sounds like a whole other problem.

                  The biggest problem though is that I am adding this to an already existing database that is running on Access 97 and 2007 says some of the queries are too complex to run in 2007. So I really should worry about a solution in 97. Is there a similar Replace function in 97?

                  Comment

                  • ADezii
                    Recognized Expert Expert
                    • Apr 2006
                    • 8834

                    #24
                    Originally posted by AKdlm
                    So I converted the database to 2007 to test this out just for kicks, and the replace statement you suggested works amazingly. I can't get it to work for multiple images, and now the insert hyperlink is adding a double file path in 2007 - meaning if the path is C:\pictures\ima ge it is adding it as C:\pictures\ima geC:\pictures\i mage so now the report won't pull up any new entries I make. This sounds like a whole other problem.

                    The biggest problem though is that I am adding this to an already existing database that is running on Access 97 and 2007 says some of the queries are too complex to run in 2007. So I really should worry about a solution in 97. Is there a similar Replace function in 97?
                    Make a slight adjustment for Access 97:
                    Code:
                    If Not IsNull(Me![ImageFilePath1]) Then
                      Me!ImageFrame1.Picture = Mid$(Me![ImageFilePath1], 2, Len(Me![ImageFilePath1]) - 2)
                    End If

                    Comment

                    • AKdlm
                      New Member
                      • Oct 2008
                      • 7

                      #25
                      Beautiful!!! ADezii, you have no idea how much this has plagued me.

                      That worked amazingly and I have it going for all 4 images on the report. It has made me aware of one more problem that maybe you can help with though. On my form where they initially add the hyperlink, I've enabled a command button to open the insert hyperlink menu. If they click the "use relative path for hyperlink" checkbox, then it will do the ..\folder\image s\image843.jpg etc.

                      The first problem was trying to open this as a hyperlink, which you've corrected with removing the #'s at the beginning and end of the file path. But now if they use a relative path instead of the absolute path, when the report opens, Access tries to open "..\folder\imag es\image843.jpg " instead of the absolute path. And now since it is text and hot a hyperlink, it will not open the file.

                      So, is there a way to make sure all paths are saved as absolute paths? Or to disable relative paths? Maybe change what you gave me to turn relatives into absolutes also?

                      Thanks again, I so appreciate the help.

                      Comment

                      • ADezii
                        Recognized Expert Expert
                        • Apr 2006
                        • 8834

                        #26
                        Originally posted by AKdlm
                        Beautiful!!! ADezii, you have no idea how much this has plagued me.

                        That worked amazingly and I have it going for all 4 images on the report. It has made me aware of one more problem that maybe you can help with though. On my form where they initially add the hyperlink, I've enabled a command button to open the insert hyperlink menu. If they click the "use relative path for hyperlink" checkbox, then it will do the ..\folder\image s\image843.jpg etc.

                        The first problem was trying to open this as a hyperlink, which you've corrected with removing the #'s at the beginning and end of the file path. But now if they use a relative path instead of the absolute path, when the report opens, Access tries to open "..\folder\imag es\image843.jpg " instead of the absolute path. And now since it is text and hot a hyperlink, it will not open the file.

                        So, is there a way to make sure all paths are saved as absolute paths? Or to disable relative paths? Maybe change what you gave me to turn relatives into absolutes also?

                        Thanks again, I so appreciate the help.
                        So, is there a way to make sure all paths are saved as absolute paths? Or to disable relative paths? Maybe change what you gave me to turn relatives into absolutes also?
                        Yes, instead of the Insert Hyperlink Dialog Box, open up the standard Office File Dialog, select a File, then copy it to a Field on a Form Bound to a Hyperlink Data Type. It will now be stored as an Absolute Path Hyperlink. Download the Test Database to see what I mean.

                        Comment

                        Working...