working with images on a form

  • Thread starter Thread starter ChrisWilliamson
  • Start date Start date
C

ChrisWilliamson

Guest
Hi guys, another newbie to access here!

I'm trying to set up a system here at work where people can add digital photos to a client database (existing). I've set up the tables & relationships, so I have a table with an OLE object field.

What I want to do is have a form with a space where the picture will be embedded, & buttons down the side for 'insert picture from disk' 'delete picture' etc etc.

I've found the 'acOLEInsertObjDlg' code to bring up the insert object dialog, but I am unsure of the format needed for this code on the button to insert the object into the OLE control...

Another related problem is when I insert a JPEG image from file, it only displays an icon on the form, not the picture. If I insert a BMP file it displays fine... I'm trying to make this as easy to use as possible - hopefully avoiding having to copy the images onto HDD first (they will be brought in on floppy) & hopefully avoiding having to convert them to BMP files

Thanks in advance for any help!! :)

Chris
 
I, too, am having the same exact problem and would appreciate any advice, help, code, or whatever anybody can give to help me get this problem resolved.

Chris, if you end up getting an answer that solves your dilemma, could you please either send me a notification that someone replied, or even better, forward their solution to me at:

overdood11@hotmail.com ?????

It would be immensely appreciated!!!
 
I think the way OLE Objects work is that they take only Bitmaps (this is what I read) they do not handle JPG's when you are trying to embed something there. i.e. your image is converted into a BMP and put there. One of the other problems is that it bloats the size of the database considerably. What you might want to do is that setup text fields instead of OLE objects. Store the image path in those text fields and then on initiate event of the form will take these paths from the tables and display images. This way the images remain seperate from the database preventing it from bloating in size. When you click the insert button all you have to do is call a file dialog and store the file name in the table. I hope this is clear if not I will post an example just let me know.
 
Well, here's actually what's going on. A separate, self-contained ID card application has generated the database, and one of the things it does is actually embed the pictures into the database. So, they are already in there, with every entry in the 'picture" field reading "long binary data." Plus, I can export them from access through the ID application and turn them back into .jpgs as well. So what I really need to do, is find the control or directX control that can turn that "long binary data" back into the pictures and just display them. Even more convenient, is that I can export the images so that they have the same exact file name as the corresponding record does in the primary table... i.e.. once exported to a directory, the viewable picture RIV10082 directly corresponds to the correct record in the access.mdb file for Member RIV10082.

I could not figure out how to re-convert the long binary data, so I gave up and opted for just having the form pull from the folder that I exported the jpgs to since that seemed easier.

So, either way works for me. If you can tell me how to just translate the binary data back to a jpg so it will display within the form, that would be ideal. My present employer is paying me to make it work that way.... I understand the concept of the extra step to get the jpgs to display, but none of the other people that are actually going to be using the form have received any Nobel Prizes recently, if you catch my drift here.

So, I hope that helps. Seems to me like it should be a piece of cake for someone who really knows Access or Visual Basic, but I am not that someone.... I'm much more of a nuts and bolts/hardware kind of person.

Thanks in advance!!!
Overdood
 
Solution and same problem

Dim dbPath As String
Private Sub Command6_Click()
getFileName
End Sub
Private Sub Form_Current()
Dim res As Boolean
Dim fName As String


On Error Resume Next
errormsg.Visible = False
fName = dbPath & Me![ctrlPicture]


Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
End Sub
Sub showImageFrame()
Me![ImageFrame].Visible = True
End Sub
Sub getFileName()

Dim fileName As String
Dim result As Integer

With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Izaberite sliku"
.Filters.Add "all files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 2
.AllowMultiSelect = False
.InitialFileName = dbPath
result = .Show
If (result <> 0) Then
fileName = Right(Trim(.SelectedItems.Item(1)), InStr(StrReverse(Trim(.SelectedItems.Item(1))), "\") - 1)
Me![ctrlPicture].Visible = True
Me![ctrlPicture].SetFocus
Me![ctrlPicture].Text = fileName
Me![ctrlPicture].SetFocus
End If
End With
End Sub
Private Sub Form_Open(Cancel As Integer)
dbPath = CurrentProject.Path & "\Pictures\"
DoCmd.Maximize
End Sub
--------------
and that works fine....
but now I have long binary data field....and I think it represents Graph object but I can't read it. when I dblclick it in Table I get 'A problem occured while MS Access was communicating with OLE server Or Active x control' msg....
Help, please
 

Users who are viewing this thread

Back
Top Bottom