Image Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghowells
    New Member
    • Oct 2006
    • 6

    Image Database

    I've been trying to create an image database using Access 2000 linked to all the images on our server, as per the instructions on the microsoft website.

    The code to link the photos is as follows:

    Private Sub Form_Current()
    On Error Resume Next
    If Not IsNull(Me![ImagePath]) Then
    Me![Imageframe].OLETypeAllowed = 1
    Me![Imageframe].SourceDoc = Me![ImagePath]
    Me![Imageframe].Action = 0
    End If
    End Sub

    Sub ImagePath_After Update()
    On Error Resume Next
    Me![Imageframe].OLETypeAllowed = 1
    Me![Imageframe].SourceDoc = Me![ImagePath]
    Me![Imageframe].Action = 0
    End Sub

    It then tells you to add to the properties of the 'unbound object frame'

    Enabled = Yes<BR/>
    Locked = No

    I take it that <BR/> is By Row, so the image frame picks up the path on that row, and shows a different image per row.

    The problem is that when the form/code is run all the images are referenced to the row that is clicked on/current, and when you use the properties box to try to change Yes to Yes<BR/> it won't allow the change and only allow Yes or No.

    I've been trying to fix it for days can anyone help, it would be much appreciated.
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Hi

    :)

    In fact according your code and the unbound control object you will have ever time the current image!

    I don't thinj that the problem is in <BR> I think this is a tog from Internet...

    There it's sure you can't add it!

    Coz it's property from type Boolean with only 2 values accepted : True or False

    I suggest you to change the type of your Image as Bound Control and bound it to OLE Field in your database...

    So all images will be linked in those controls! But your database will increase in size....

    And the link will be enough slow 10 seconds per image! I do the same with Corel Draw! But not all images - only needed!

    :)

    Comment

    • ghowells
      New Member
      • Oct 2006
      • 6

      #3
      Thanks for all your help.

      I managed to get the images to show correctly on a single form, but will only show one image on a continuous form, presumably because it only sees one record at a time as being current, by using this code:

      Function setImagePath()
      Dim strImagePath As String
      On Error GoTo PictureNotAvail able
      strImagePath = Me.txtImageName
      Me.ImageFrame.P icture = strImagePath
      Exit Function
      PictureNotAvail able:
      strImagePath = "C:\Windows\NoP icture.BMP"
      Me.ImageFrame.P icture = strImagePath
      End Function

      then adding =setImagePath() to OnCurrent and AfterUpdate. this seems to work quite efficiently.

      The idea is to be able to create a search of an image database and produce the results as a contact sheet.

      I understand the problem would be the amount of images that the form could potentially generate would be too many for it to handle, but i could possibly limit the form to 10 records or maybe hide the form and go straight to a report.

      Are there any ideas as to how i can get the continuous form to display many images based on the filepath saved in the corresponding record.

      All your help is very much appreciated.

      Comment

      • PEB
        Recognized Expert Top Contributor
        • Aug 2006
        • 1418

        #4
        As u say this approach is good when u have single form! And u can apply it only in single form to visualize a picture!

        If u want to visualize more than one picture in a form or in a report.... u need ur pictures to be in an OLE object that is bound!

        I can imagine that u have all images as paths, so it isn't easy to import them!


        so the only thing that i can help u is to show u the function that inserts into OLE bound control a number of wanted Corel Draw informations:

        See how it is done:
        I have a form and control on it:
        FORM:Link_OLE
        CONTROL:OLE1

        Code:
        Function link_Corel_from_liste(listes) As Integer
        On Error GoTo Err_link
        Dim draw As Object, draw1 As Object
        Dim mydb As Database
        Dim mys As Recordset
        Dim myr As Recordset
        Dim recs
        Dim currmys
        Dim p, mysr
        Dim xx As Long, yy As Long
        Dim i As Integer
        'Stop
        Set mydb = CurrentDb()
        Set mys = mydb.OpenRecordset(listes) '"SELECT OAS.n°Cde AS Criteria, OAS.Pic_path AS SourceDoc, 'CorelDRAW 11.0 Graphic' AS Class, 0 AS OLETypeAllowed, '' AS SourceItem, 1 AS [Action], 3 AS SizeMode FROM OAS WHERE (((OAS.Pic_path) Like 'Y:\*')) ORDER BY OAS.n°Cde;"
        'Set myr = Forms!Link_OLE.RecordsetClone
        If mys.RecordCount = 0 Then Exit Function
        mys.MoveLast
        mysr = mys.RecordCount
        currmys = 1
        mys.MoveFirst
        recs = Forms!Link_OLE.Recordset.RecordCount
        DoCmd.GoToRecord , "Link_OLE", acFirst
        
        If fIsAppRunning("Corel") = False Then
            Set draw1 = GetObject(mys("[Pic_path]"))
        End If
        Set draw = CreateObject("CorelDraw.Automation.11")
        
        For p = 0 To recs - 1
        check_link1:
            If mys("Criteria") = Forms!Link_OLE!Memo Then
                draw.FileOpen mys("[Pic_path]")
                draw.SelectAllObjects
                'draw.Getsize xx, yy
                'draw.SelectObjectsInRect -972111, 0, 2172111, 2044737, True
                draw.CopyToClipboard
        'Forms!Link_OLE!OLE1.Class = "CorelDRAW 11.0 Graphic"
                Forms!Link_OLE!OLE1.Action = acOLEPaste
                Forms!Link_OLE!OLE1.SizeMode = mys("SizeMode")
        '        Stop
        '        Debug.Print Forms!Link_OLE!OLE1.Height
        '        Debug.Print Forms!Link_OLE!OLE1.Width
        '        Forms!Link_OLE!OLE1.Height = Forms!Link_OLE!OLE1.Height * 3
        '        Forms!Link_OLE!OLE1.Width = Forms!Link_OLE!OLE1.Width * 3
                draw.FileClose
                If mysr > currmys Then
                    mys.MoveNext
                    currmys = currmys + 1
                End If
                DoCmd.GoToRecord , "Link_OLE", acNext
                Debug.Print Now
            Else
                If mys("Criteria") > Forms!Link_OLE!Memo Then
                
                DoCmd.GoToRecord , "Link_OLE", acNext
                Else
                    If mysr > currmys Then
                        mys.MoveNext
                        currmys = currmys + 1
                        GoTo check_link1
                    End If
                End If
            End If
        Next p
        mys.Close
        mydb.Close
        Set draw = Nothing
        Set draw1 = Nothing
        Exit Function
        
        Err_link:
        MsgBox ErrorString(Err.NUMBER)
        If Err.NUMBER = 2105 Then
            Forms!Link_OLE.Undo
            DoCmd.GoToRecord , "Link_OLE", acNext
        End If
        Resume Next
        End Function
        Good luck!

        Originally posted by ghowells
        Thanks for all your help.

        I managed to get the images to show correctly on a single form, but will only show one image on a continuous form, presumably because it only sees one record at a time as being current, by using this code:

        Function setImagePath()
        Dim strImagePath As String
        On Error GoTo PictureNotAvail able
        strImagePath = Me.txtImageName
        Me.ImageFrame.P icture = strImagePath
        Exit Function
        PictureNotAvail able:
        strImagePath = "C:\Windows\NoP icture.BMP"
        Me.ImageFrame.P icture = strImagePath
        End Function

        then adding =setImagePath() to OnCurrent and AfterUpdate. this seems to work quite efficiently.

        The idea is to be able to create a search of an image database and produce the results as a contact sheet.

        I understand the problem would be the amount of images that the form could potentially generate would be too many for it to handle, but i could possibly limit the form to 10 records or maybe hide the form and go straight to a report.

        Are there any ideas as to how i can get the continuous form to display many images based on the filepath saved in the corresponding record.

        All your help is very much appreciated.

        Comment

        • ghowells
          New Member
          • Oct 2006
          • 6

          #5
          Thankyou for all your help.

          It may be a while before i can get to using it, restriction on my time at the moment. But i will let you know how it goes.

          Comment

          Working...