?
Solved

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

Posted on 2004-08-29
15
Medium Priority
?
443 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 500 total points
ID: 11926130
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 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