Solved

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

Posted on 2004-08-29
15
441 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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