Solved

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

Posted on 2004-08-29
15
434 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
  • 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
 

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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
microsoft access - xml 10 29
Access MDB/PDF 21 32
Dlookup issue 4 15
In or Between 2 0
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now