Results 1 to 9 of 9

Thread: Access 2000 Ole Object in Report

  1. #1
    Join Date
    May 2009
    Posts
    5

    Access 2000 Ole Object in Report

    I have a table with an Ole Object data type field. In this field I have inserted images in binary form. When I look at the table the fields displays "Long Binary Data".

    I've created a report with a bound object frame bound to the ole object field. When I run the report there is no image. When I double-click the field in the table I get the following error: "A problem occurred while communicating with the ole server..." ..."Restart the ole server outisde Access and try again."

    Nothing is working. Any ideas?

  2. #2
    Join Date
    May 2006
    Posts
    407
    You say you have inserted images in binary form. How did you insert the images?

    I just inserted an image into an OLE object data type field by using the Insert menu, Object... option, then selecting "Create from File" radio button, then clicking Browse... and selecting a .jpg image from my hard drive. Then the field in the table has this text displayed: "Microsoft Photo Editor 3.0 Photo." Microsoft's Photo Editor is the program that on my system is defined as the program that is the default photo editor.

    So if you explained how you insert the binary data (which is a photo) into the OLE Object field within the table, that would be a big help to being able to help you.

  3. #3
    Join Date
    May 2009
    Posts
    5
    Good point. I suppose I didn't explain that very well.

    I have a function which I got from vbforums.com codebank. I modified it slightly and use it in my application. (I have an app I created in VS 2008, I just create/run reports directly from Access at this point)

    http://www.vbforums.com/showthread.php?t=469562

    This function returns a bitmap (barcode) which I then insert into the database.

    The problem exists when I attempt to run a Report.

    On my report, I have a bound object frame which correlates to the ole object field in my table.

    The report does not display the image.

    This whole process of saving images to a database is comletely new to me.

    I have Microsoft Photo Editor installed. I think MSDN told me that if the field in the table displayed "Long binary data" then I needed to have some sort of "ole server".

    Of course any help is greatly appreciated.

  4. #4
    Join Date
    May 2006
    Posts
    407
    1. Are you using Access or SQL Server to store the binary data?
    2. Could you post the code you have used from the sample you found at vbforums?

  5. #5
    Join Date
    May 2009
    Posts
    5

    Access 2000 Ole Object

    Access 2000

    Here is the VB code:

    Code:
    Imports System
    Imports System.Drawing
    Imports System.Drawing.Printing
    
    
    Public Class Code128_CharacterSetB
    
        Private bitsCode As ArrayList
    
        Public Sub New()
            bitsCode = New ArrayList
            bitsCode.Add("11011001100")
            bitsCode.Add("11001101100")
            bitsCode.Add("11001100110")
            bitsCode.Add("10010011000")
            bitsCode.Add("10010001100")
            bitsCode.Add("10001001100")
            bitsCode.Add("10011001000")
            bitsCode.Add("10011000100")
            bitsCode.Add("10001100100")
            bitsCode.Add("11001001000")
            bitsCode.Add("11001000100")
            bitsCode.Add("11000100100")
            bitsCode.Add("10110011100")
            bitsCode.Add("10011011100")
            bitsCode.Add("10011001110")
            bitsCode.Add("10111001100")
            bitsCode.Add("10011101100")
            bitsCode.Add("10011100110")
            bitsCode.Add("11001110010")
            bitsCode.Add("11001011100")
            bitsCode.Add("11001001110")
            bitsCode.Add("11011100100")
            bitsCode.Add("11001110100")
            bitsCode.Add("11101101110")
            bitsCode.Add("11101001100")
            bitsCode.Add("11100101100")
            bitsCode.Add("11100100110")
            bitsCode.Add("11101100100")
            bitsCode.Add("11100110100")
            bitsCode.Add("11100110010")
            bitsCode.Add("11011011000")
            bitsCode.Add("11011000110")
            bitsCode.Add("11000110110")
            bitsCode.Add("10100011000")
            bitsCode.Add("10001011000")
            bitsCode.Add("10001000110")
            bitsCode.Add("10110001000")
            bitsCode.Add("10001101000")
            bitsCode.Add("10001100010")
            bitsCode.Add("11010001000")
            bitsCode.Add("11000101000")
            bitsCode.Add("11000100010")
            bitsCode.Add("10110111000")
            bitsCode.Add("10110001110")
            bitsCode.Add("10001101110")
            bitsCode.Add("10111011000")
            bitsCode.Add("10111000110")
            bitsCode.Add("10001110110")
            bitsCode.Add("11101110110")
            bitsCode.Add("11010001110")
            bitsCode.Add("11000101110")
            bitsCode.Add("11011101000")
            bitsCode.Add("11011100011")
            bitsCode.Add("11011101110")
            bitsCode.Add("11101011000")
            bitsCode.Add("11101000110")
            bitsCode.Add("11100010110")
            bitsCode.Add("11101101000")
            bitsCode.Add("11101100010")
            bitsCode.Add("11100011010")
            bitsCode.Add("11101111010")
            bitsCode.Add("11001000010")
            bitsCode.Add("11110001010")
            bitsCode.Add("10100110000")
            bitsCode.Add("10100001100")
            bitsCode.Add("10010110000")
            bitsCode.Add("10010000110")
            bitsCode.Add("10000101100")
            bitsCode.Add("10000100110")
            bitsCode.Add("10110010000")
            bitsCode.Add("10110000100")
            bitsCode.Add("10011010000")
            bitsCode.Add("10011000010")
            bitsCode.Add("10000110100")
            bitsCode.Add("10000110010")
            bitsCode.Add("11000010010")
            bitsCode.Add("11001010000")
            bitsCode.Add("11110111010")
            bitsCode.Add("11000010100")
            bitsCode.Add("10001111010")
            bitsCode.Add("10100111100")
            bitsCode.Add("10010111100")
            bitsCode.Add("10010011110")
            bitsCode.Add("10111100100")
            bitsCode.Add("10011110100")
            bitsCode.Add("10011110010")
            bitsCode.Add("11110100100")
            bitsCode.Add("11110010100")
            bitsCode.Add("11110010010")
            bitsCode.Add("11011011110")
            bitsCode.Add("11011110110")
            bitsCode.Add("11110110110")
            bitsCode.Add("10101111000")
            bitsCode.Add("10100011110")
            bitsCode.Add("10001011110")
            bitsCode.Add("10111101000")
            bitsCode.Add("10111100010")
            bitsCode.Add("11110101000")
            bitsCode.Add("11110100010")
            bitsCode.Add("10111011110")
            bitsCode.Add("10111101110")
            bitsCode.Add("11101011110")
            bitsCode.Add("11110101110")
            bitsCode.Add("11010000100")
            bitsCode.Add("11010010000")
            bitsCode.Add("11010011100")
            bitsCode.Add("1100011101011")
        End Sub
    
    
        Public Function Generate(ByVal Code As String) As Image
            Dim bmp As Image
            Dim ValidInput As String = " !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
            Dim CheckSum As Integer
            Dim BarCode As String
            Dim i As Integer
    
            If Code = "" Then Throw New Exception("Le code est incorrect")
            BarCode = bitsCode(104)
            For i = 0 To Code.Length - 1
                If ValidInput.IndexOf(Code.Substring(i, 1)) = -1 Then Throw New Exception("Le code est incorrect")
                CheckSum += ((i + 1) * ValidInput.IndexOf(Code.Substring(i, 1)))
                BarCode &= bitsCode(ValidInput.IndexOf(Code.Substring(i, 1)))
            Next
            CheckSum += 104 'Start B     
            CheckSum = CheckSum Mod 103
            BarCode &= bitsCode(CheckSum)
            BarCode &= bitsCode(106) 'Stop symbol 
    
            bmp = New Bitmap(BarCode.Length, 58)
            Dim g As Graphics = Graphics.FromImage(bmp)
            g.FillRectangle(New SolidBrush(Color.White), 0, 0, BarCode.Length, 58)
            Dim p As New Pen(Color.Black, 1)
            Dim BarX As Integer
    
            ' Create font and brush.      
            Dim drawFont As New Font("Arial", 8)
            Dim drawBrush As New SolidBrush(Color.Black)
            ' Create point for upper-left corner of drawing.   
            Dim y As Single = 42
            ' Set format of string.        
            Dim drawFormat As New StringFormat
            drawFormat.FormatFlags = StringFormatFlags.NoWrap
            drawFormat.Alignment = StringAlignment.Center
    
            For i = 0 To BarCode.Length - 1
                Try
                    If BarCode.Chars(i) = "1" Then g.DrawLine(p, BarX, 0, BarX, 40)
                    BarX += 1
                Catch ex As Exception
    
                End Try
            Next
    
            g.DrawString(Code, drawFont, drawBrush, New RectangleF(0, y, BarCode.Length, 16), drawFormat)
    
            Return bmp
    
        End Function
    
    
    End Class

  6. #6
    Join Date
    May 2006
    Posts
    407
    The reason mine worked is that my computer knows that a .jpg image is open by default by the Microsoft Photo Editor. And I used the User Interface to load the .jpg into the database. Because you have this VB code that loads the binary data into the database, I'm assuming there must be a step or property that you can set to let this OLE Object know that you have loaded a .jpg (or whatever) formatted image into the database. Once the OLE Object field is set to know what the actual type of data is in the record, then (I believe) when you use that field on a report, Access will know how to handle that data. That knowledge will point Access to your "OLE server" which in my sample case was the Microsoft Photo editor. I know this is not the answer, but I do hope it helps you in your seach for the answer.
    Thank you very much for helping by posting what I asked for.

  7. #7
    Join Date
    May 2009
    Posts
    5
    I certainly appreciate your help.

  8. #8
    Join Date
    May 2006
    Posts
    407
    You are welcome. When you find the solution to your situation, please post it here to help others in the months to come.

  9. #9
    Join Date
    May 2009
    Posts
    5
    I certainly will. These forums have helped me tremendously and I plan on "paying it forward" every opportunity I get.

Posting Permissions

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