Consulting

Results 1 to 5 of 5

Thread: Images in MS Access 2010

  1. #1

    Images in MS Access 2010

    I have a field in my database that contains a Jpeg. I have written a VBA module to transfer field data from the database to a MS Word document , the text transfers fine, but when I try to transfer the field with the image it generates an error.
    Is it possible to transfer an image between Access and Word?

  2. #2
    It would help to know what your VBA does.

    Are you using automation to perform a mail merge with Word 2010?
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    HiTechCoach

    The code basically creates a new word document, draws a table and populates the cells with the database data .

    Example of code is
    ' Get the data from the database
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("ITEM")
    Set fldloc = rs.Fields("LOCATION")
    Set fldequip = rs.Fields("DESCRIPTION")
    Set fldpriatt = rs.Fields("PRIMARY")
    Set fldsecatt = rs.Fields("SECONDARY")
    Set fldinspect = rs.Fields("EQUIPMENT")
    Set fldcontrol = rs.Fields("CONTROL")

    ' Pass the data from database recordset to table
    Do Until rs.EOF
    Set oRow = oTable.Rows.Add
    myRow.Cells(4).Range.Font.ColorIndex = wdRed
    myRow.Cells(1).Range.Text = fldloc
    myRow.Cells(2).Range.Text = fldequip
    myRow.Cells(3).Range.Text = fldpriatt & vbCrLf & fldsecatt
    myRow.Cells(4).Range.Text = fldinspect
    myRow.Cells(5).Range.Text = "Signature"

    rs.MoveNext
    Loop

    The other field that exists in the database that I would like to transfer is a photo. Ideally what I am trying to achieve is to see a thumbnail size photo in the document and have a hyperlink to the parent photo file on the disk.

    I am a newbie to VBA and am using this as a project to teach myself.

    Hope this explains a little better.

  4. #4
    Where are you storing the photo?
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  5. #5
    HiTechCoach,

    I am planning to use a fixed folder structure, in that:

    Main Folder
    -Database
    -Photographs
    -Word Reports
    This way any user will follow the same process and save all photos to the relevant folder.
    Then when they create a new record in the report they access the folder from the attachments field.
    In the mean time I have created another textbox in the form where the user has to insert the photo file name and because the file folder structure will be fixed I have just used this line to add the picture.

    oRow.Cells(1).Range.InlineShapes.AddPicture photoloc, linktofile:=False,_ savewithdocument:=True

    where photoloc is a string pointing to the folder with file name from field added on the end.

    A little scruffy but it has allowed me to progress.

    In an ideal world I was trying to use the information already stored in the attachment.
    When I create a query and look at the attachment field I see something similar to this:-
    - Field1
    Field1.FileData
    Field1.FileName
    Field1.FileType
    I was trying to tap into this info to get the file name for the picturebox and for the hyperlink, but it doesn't appear possible(beginner talking).

    Thanks for the interest in my problem.

    Mick

Posting Permissions

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