Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

i cant embed a .bmp file in access

Discussion in 'Information Technology' started by kerry, Jul 28, 2006.

  1. kerry

    kerry
    Expand Collapse
    Guest

    I have acess 2003. I cant embed (not link) a .bmp file in an access OLE
    field. It just inserts it as a package. Reading the help .bmp files should be
    able to be inserted.
    Can anyone help
     
  2. Loading...

    Similar Threads Forum Date
    Cant believe its Chistmass Blogs Oct 17, 2015
    Opinion Violence Significantly Alters Children's DNA, Causes Premature Aging Breaking News Apr 25, 2012
    UK Archbishop of Canterbury Visits Hounslow Sikh Temple Breaking News Oct 19, 2011
    Sikhism Intoxicants and Pleasure Videos Jul 10, 2011
    India Binyat Sen's Contribution Significant in Chhattisgarh's "Mitanin" Programme Breaking News May 20, 2011

  3. Guy Fenn

    Guy Fenn
    Expand Collapse
    Guest

    Hi Kerry

    I use this routine to store Excel templates in a database. It should do for
    bmps.
    (ADO 2.5 or above)

    Function WriteStream() As Boolean
    '**************************************************************
    ' Creates a file from a copy stored in the database.
    '**************************************************************

    On Error GoTo Err_out

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim DataStream As ADODB.Stream
    Dim strFileName As String
    Dim sql As String
    Dim ID As String

    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set DataStream = New ADODB.Stream
    Set cn = CurrentProject.Connection

    ID = 0
    strFileName = "C:\path\your file.bmp"

    If Len(strFileName) <> 0 Then

    sql = "SELECT ObjData FROM tblBINARY WHERE ID = 0"

    rs.Open sql, cn, adOpenKeyset, adLockOptimistic

    DataStream.Type = adTypeBinary
    DataStream.Open
    DataStream.Write rs.Fields("ObjData").Value

    DataStream.SaveToFile strFileName, adSaveCreateOverWrite

    rs.Close
    cn.Close

    WriteStream = True

    Else

    WriteStream = False

    End If

    Exit_out:

    Exit Function

    Err_out:

    MsgBox Err.Description, vbCritical, "modFunctions - FWriteStream"

    End Function

    Function ReadStream() As Boolean
    '******************************************
    ' Stores file in binary format in the database.
    '******************************************

    On Error GoTo Err_out

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim DataStream As ADODB.Stream
    Dim strFileName As String

    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set DataStream = New ADODB.Stream
    Set cn = CurrentProject.Connection

    DataStream.Type = adTypeBinary
    DataStream.Open

    strFileName = "C:\path\your file.bmp"

    DataStream.LoadFromFile strFileName

    rs.Open "SELECT * FROM tblBINARY WHERE ID = 0", cn, adOpenDynamic,
    adLockOptimistic

    With rs.Fields

    !ObjData.Value = DataStream.Read

    End With

    rs.Update

    rs.Close
    cn.Close

    ReadStream = True

    Exit_out:

    Exit Function

    Err_out:

    MsgBox Err.Description, vbCritical, "modFunctions - ReadStream"

    End Function

    Guy Fenn
    (Victoria, B.C.)

    "kerry" <kerry@discussions.microsoft.com> wrote in message
    news:0FFF32A3-7F8F-4DED-81BD-9D30CFA57C7A@microsoft.com...
    >I have acess 2003. I cant embed (not link) a .bmp file in an access OLE
    > field. It just inserts it as a package. Reading the help .bmp files should
    > be
    > able to be inserted.
    > Can anyone help
     
  4. Wayne-I-M

    Wayne-I-M
    Expand Collapse
    Guest

    Hi Kerry

    The method shown on the MS website is to "link" pictures but if you really
    want to embed your pictures (remember that this will enlarge the file size of
    your DB).



    BMP = Windows Bitmap this is best option
    GIFF CompuServe Bitmap is also OK
    JPEG’s “will†work but they are not really meant for this type of application
    TIFF’s are not supported by most access versions.


    So :-

    Make copies of the pictures you want to link to your records (on C Drive /
    hard disk) and save them as
    ThumbnailPicture1,
    ThumbnailPicture2,
    ThumbnailPicture3,
    etc, (or use the ID of the record in the table)

    If you have a picture processing programme such as Photoshop or Photopaint
    then use that to resample and convert. If you don’t have one of these
    programmes:

    1 Click start
    2 Click My Pictures (if that’s where they are)
    3 Right click the picture and select “Open Withâ€
    4 Select Windows Office Picture Manager
    5 After the picture is open click the Picture Menu then select Resize
    6 Resize your picture to the correct size
    NOTE. You will need to know the pixel size of your OLE box see below
    7 SaveAS a copy of the original (DON’T JUST SAVE or you will ruin the
    original picture)

    BMP Windows Bitmap this is best option
    GIFF CompuServe Bitmap is also OK
    JPEG’s “will†work but they are not really meant for this type of
    application REMEMBER that JPEG’s are reducing formats – so each time you
    change and save you will lose some resolution.

    Create an OLE field in the table (use this OLE field on your form if you
    wish to display the picture on a form with a particular record)


    To link your picture thumbnail with the OLE
    8 Open the Table that will hold the data /picture (not the form)
    9 navigate to the OLE field on the correct record and Right Click
    10 Select Insert Object
    11 Select Create From File and then Bitmap and then check the Link option
    12 Browse to your picture and select it
    13 Click OK
    14 “Package†will appear in the field
    15 View your image on the form


    Some notes on the size of your OLE object – regardless of what anyone will
    tell you there is no way of converting pixels to cm’s – which your OLE object
    will be sized in, UNLESS you know the size of each pixel or even the screen
    resolution and as screens are all different sizes and resolutions this simply
    isn’t possible here, so I have given the APPROXIMATE conversions here you
    will have to gig about with your thumbnail until it fits your OLE. Better
    still save all the thumbnails as size that you’re happy with and resize your
    OLE to fit this.
    On a screen resolution of 1024 Pixels X 768 (this is standard High Res for a
    lap top)
    5mm = 118 Pixels or 14.173 Points
    1cm = 236 Pixels or 28.346 Points
    So you can work out that say 3.5cm would be 827 Pixels or 99.213 Points


    Hope this helps and points you in the right direction


    --
    Wayne
    Manchester, England.



    "kerry" wrote:

    > I have acess 2003. I cant embed (not link) a .bmp file in an access OLE
    > field. It just inserts it as a package. Reading the help .bmp files should be
    > able to be inserted.
    > Can anyone help
     
  5. Wayne-I-M

    Wayne-I-M
    Expand Collapse
    Guest

    Hi Kerry (again)

    Hope that by now you have read my last post about this and if this is not
    what you're after here is another method of embedding pics on to a DB

    I take it you have already tried the F1 (help) method) but if you are not
    getting the results you want by following the F1 instructions try this - not
    saying F1 won’t work it's just better this way (as you pictures will be
    auto-sized to fit the OLE box on
    your form).

    So

    If all else fails and you "really" do want to embed and not link.
    _____________________________________

    Open the main table (not the form) that will hold the data (inc. pictures).

    Right click the OLE field and use the "Insert Object" button.

    Next (still on the OLE field drop down) - Click CreateNew and click Bitmap
    on the dropdown. This will open MS paint programme.

    Click "Paste From" (it's one of the options on the Edit menu)

    Select the saved picture from your hard drive and click save (give it a new
    name if you want)

    Select Update and exit the table

    Check out the form form



    --
    Wayne
    Manchester, England.
     

Share This Page