Solved

Help in Inserting Picture (jpg,bmp,etc..) in a table ---- OLE OBJECT

Posted on 2004-08-29
15
440 Views
Last Modified: 2008-02-01
I know this ought to be simple and easy.. and I  might need it right away.. who knows what could happen.. :)

I got this database with a table named "users" with ID, NAME, PICTURE as fields
ID and NAME are strings while PICTURE is an OLE Object field...

these are about 100+ records and I got also 100+ jpg pictures in a folder for each user.. How do I put all of those pictures in the OLE Object field (batch) with a VBA procedure/function

and what is the library of ADODB.STREAM.. I cant seem to find it.. (no STREAM option in ADODB)

thanks,
RLBE
0
Comment
Question by:RLBE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
15 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11926001
Don't store pictures in an OLE field. You'll get an enormous amount of database bloat - you can expect a 30KB JPG to increase your db size by about 1MB.

Instead, just store the filename and path of the JPG file against each record and when you need to display them, set an Image control's Picture property.
0
 

Author Comment

by:RLBE
ID: 11926089
hmmm..

but just in case I need to insert the picture in the Ole object itself with VBA code, how is it done...

or correctly done? Im not considering the bloat factor that much now...

thanks in advance...
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 125 total points
ID: 11926130
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:RLBE
ID: 11926251
I cant seem to understand how the [OLE***] works since I cant get the "." values... (in the link given above, ie. ".sourcedoc" ".action", etc...)

sorry.. anyway.. I might not understand since Im focused in a single function anway I'm stuck at this code and got errors on anything else I try..

--------------------------
--------------------------

Function picuser()
On Error GoTo eer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim path
Set db = CurrentDb
Set rs = db.OpenRecordset("users", dbOpenDynaset)
rs.MoveFirst
While rs.EOF = False

rs.Edit
path = "C:\images\" & rs.Fields("issn") & ".jpg"

rs.Fields("picture") = path                                        'the OLE object // not working this is not right
rs.Update

eer:
rs.MoveNext
Wend

End Function
0
 

Author Comment

by:RLBE
ID: 11926267
sorry.. I forgot.. i renamed ID field to "issn"
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11926291
That simply won't work, I'm afraid. You need to follow the instructions in the article - read it carefully, you need to create a form with an OLE object frame in it, based (in this case) on your customers table. Let me know which parts of the article you're having difficulty with.
0
 

Author Comment

by:RLBE
ID: 11926335
okay.. Im going to work on the sample code from the form right away...
0
 

Author Comment

by:RLBE
ID: 11926420
I followed exactly the instructions on the link...

I also got a bmp file in the folder and jpg's (is paint.picture applicable to jpg too?)

now there is no output.. the MyFile is blank as in "" (in debug) while the path is okay..

and the table still contains nothing.. :)

thanks.. :)

-------------
3 text boxes..
"the path"
*.bmp
Paint.Picture
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11926448
OK, what have you set the SearchExtension to? Can you post the code that you have actually put in your form? With the method in the link, you can only insert one type of extension at a time (i.e. you need to do bmp files first and then jpgs).
0
 

Author Comment

by:RLBE
ID: 11926502
Ah okay.. here's the code

Option Compare Database

Private Sub cmdloadole_Click()
Dim MyFolder As String
       Dim MyExt As String
       Dim MyPath As String
       Dim MyFile As String
       Dim strCriteria As String

       MyFolder = Me!searchfolder
       ' Get the search path.
       MyPath = MyFolder & "\" & "*." & [searchextension]
       ' Get the first file in the path containing the file extension.
       MyFile = Dir(MyPath, vbNormal)
       Do While Len(MyFile) <> 0
          [olepath] = MyFolder & "\" & MyFile
          [olefile].Class = [oleclass]
          [olefile].OLETypeAllowed = acOLEEmbedded
          [olefile].SourceDoc = [olepath]
          [olefile].Action = acOLECreateEmbed
          ' Check for next OLE file in the folder.
          MyFile = Dir
          ' Go to new record on form.
          ' For Access 95 only, use the following Line of code:
          DoCmd.DoMenuItem acFormBar, acEditMenu, 12, 4, acMenuVer70

          ' For Access 97 only, use the following line of code:
          'DoCmd.RunCommand acCmdRecordsGoToNew
       Loop
 End Sub

0
 

Author Comment

by:RLBE
ID: 11926506
I just copied it directly so as not to incurr errors...
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11926524
OK, what did you type into the SearchExtension text box when you ran the code? Try typing in just:
bmp

and see what that does.
0
 

Author Comment

by:RLBE
ID: 11926572

geesh.. I forgot.. sorry, I didnt see that there is already an *.

thank you very much.. I got the code working now.... I'd just tweak it a little to for it to work for the one I'm solving... and automate it..

thanks for the help...

0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11926579
No problem, don't forget to close and grade this question! :-)
0
 

Author Comment

by:RLBE
ID: 11926583
thanks for the solution.. and the time.. :)

-solution accepted-
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question