Inserting photo or image

J

JB

Hi.
I've created a database for sketches and drawings which have been scanned.
In the form there is the name of the sketch, code, year etc but also I've
got a field that I want to insert the scanned image.
From what I can gather I right click in the field, choose 'insert object',
browse to find the image.

2 problems with that. One that the person who is going to use this database
and enter hundreds of sketch archives, is going to need something a lot
easier. Is this going to need coding to have buttons available ie. insert
picture.

And the other problem is that when I did choose an image, (bmp) it,
uncompressed, only the name of the file appears ie. 6524.bmp, if I compress
it the picture it appears very pixely, and has the name of the file
included. I only want to show the image.

I looked at the 'employee' form in the Northwind sample database and the
pictures there to insert are the same size as my images.
Can someone please point me in the right direction.
Thank you
Jen
 
J

JB

OK the second problem with the pixely is sorted. Did some tweaking.
Just need an easier way for the user to insert the sketch
Ta
 
D

DStegon via AccessMonster.com

Are you actually storing the picture in the database??? Why? Why not store
the pictures in a picture folder on the computer and then store the path to
the picture in your database. The user scans the picture and saves it to the
folder where all the sketches and drawings are stored. In the form have the
field for the path to the picture ( you can use UNC or if on the same
computer "C:\blah\blah.jpg"). Place an imagecontrol on the form and have the
program use the picture path to update and display the image. You can have a
Common Dialog box appear on a command button or on entering the path field
(test that it is blank) and have the person pick from the actual picture file.
I will use a ProdID as the Product (drawingID).... hopefully you can follow.

Private Sub ChangePicture(ProdID As Long)
On Error GoTo HandleErr

On Error Resume Next
Dim FileText As String
Dim cdl As CommonDlg
Dim rst As New ADODB.Recordset

Set cdl = New CommonDlg

With cdl
.DialogTitle = "Product Picture"
.hWndOwner = Me.hWnd
.InitDir = "\\YOUR_COMPUTERS_NETOWRK_NAME\pictures" 'Use "C:\pictures\....
" if on same computer
.Filter = "JPEG File Interchange Format (*.jpg)" & Chr(0) & "*.jpg; *.
jpeg" & Chr(0)
.DefaultExt = "jpg"
Call .ShowOpen
FileText = .FileName
End With

If FileText <> "" Then
With rst 'This is a separate table the holds the ProdID and the Path to
the item. Use relational table just in case not all prods have a picture
.Open "Select * FROM tbl_Product_File WHERE Product_ID=" & ProdID,
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If .eof Then .AddNew
!Product_ID = ProdID
!File_Path = FileText
.update
.Close
End With
End If

GetPicture ProdID

exithere:

Exit Sub

HandleErr:
If QueueError(Err) Then GoTo exithere: On Error GoTo 0: Resume

End Sub


Private Sub GetPicture(ProdID As Long)
Dim rst As New ADODB.Recordset
Dim strFilePath As String

On Error GoTo HandleErr

With rst
.Open "Select * From tbl_Product_File WHERE ((Product_File_Type_ID = 1)
and (Product_ID=" & ProdID & "))", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
If Not .eof Then
strFilePath = !File_Path
Else
strFilePath = ""
End If
.Close
End With

DisplayImage Me.PictureFrameSearch, strFilePath

exithere:
Exit Sub

HandleErr:
If QueueError(Err) Then GoTo exithere
Resume
End Sub


Public Function DisplayImage(ctlImageControl As Control, strImagePath As
Variant) As String
On Error GoTo Err_DisplayImage

Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer

With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = "Not Found"
Else
If InStr(1, strImagePath, "\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath, "\", Len
(strDatabasePath))
strDatabasePath = Left(strDatabasePath, intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Found"
End If
End With

Exit_DisplayImage:
DisplayImage = strResult
Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Not Found"
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "Not Found"
Resume Exit_DisplayImage:
End Select
End Function

OK the second problem with the pixely is sorted. Did some tweaking.
Just need an easier way for the user to insert the sketch
Ta
Hi.
I've created a database for sketches and drawings which have been scanned.
[quoted text clipped - 18 lines]
Thank you
Jen
 
D

DStegon via AccessMonster.com

ooopppppss ... take this

((Product_File_Type_ID = 1)

out of the select statement

With rst
.Open "Select * From tbl_Product_File WHERE ((Product_File_Type_ID = 1)
and (Product_ID=" & ProdID & "))", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

in the GetPicture sub. The example here is that each product can have a TYPE
and only "type=1" were allowed to have pictures associated. Of course the
table names and such have to be changed to match your table structure. Sorry
for any confusion.
 
L

Larry Linson

JB said:
OK the second problem with the pixely is
sorted. Did some tweaking. Just need an
easier way for the user to insert the sketch

You may very well, sooner rather than later, need a different way to store
the images because it's easy to exceed Access' storage limits -- images are
very large.
The sample imaging databases at http://accdevel.tripod.com illustrate three
approaches to handling images in Access, and the download includes an
article discussing considerations in choosing an approach. Two of the
approaches do not use OLE Objects and, thus, avoid the database bloat, and
some other problems, associated with images in OLE Objects.

If you are printing the images in reports, to avoid memory leakage, you
should also see MVP Stephen Lebans' http://www.lebans.com/printfailures.htm.
PrintFailure.zip is an Access97 MDB containing a report that fails during
the Access formatting process prior to being spooled to the Printer Driver.
This MDB also contains code showing how to convert the contents of the Image
control to a Bitmap file prior to printing. This helps alleviate the "Out of
Memory" error that can popup when printing image intensive reports.

And, Stephen has an ActiveX control available that works in cases where the
graphics filters are not available -- and works better, I've heard, than the
OLE Object and OLE Controls.

Please note that there are other approaches, e.g.,
Application.FollowHyperlink, but those, like OLE and Bound OLE Frames still
leave
you "at the mercy of the imaging software registered for the filetype".

Finally, Access 2007 has enhancements that, reputedly, eliminate the
database bloat long associated with OLE Objects and Bound OLE Frames. But,
it still leaves you relying on the software registered for the image type,
which may not be as "cooperative" as we'd like in creating our display. It
also has the capability of having a variable number of Attachments to a
Record, which may be helpful. But, as I have not done much with it yet, I
certainly wouldn't suggest you rush out and replace an earlier version --
until you have a copy incorporating, at least, the first Service Pack, or
have
the SP in hand and ready to apply as soon as you install Access 2007.

Just FYI, I'd view with some alarm answers posted by a user who's said
elsewhere that he/she never ever uses bound forms.

Larry Linson
Microsoft Office Access MVP
 
D

DStegon via AccessMonster.com

Larry said:
Just FYI, I'd view with some alarm answers posted by a user who's said
elsewhere that he/she never ever uses bound forms.

Larry Linson
Microsoft Office Access MVP


First off, take an English class!! who's = Who is NOT Who has you dipSh!+
Hmmm... "by a user who is said elsewhere... " Yeah... that makes a butt load
of sense.

Second, be a man and "name" the "user". Pansy a$$.

Third, by me informing this person that they should store the pictures
outside the DB did I do something different than you in your stupid long
winded tribe about nothing? I actually supplied code the help them. What
did you give them? blah blah blah OLE blah blah OLE Blah... just you typing
so you can can feel good about yourself it seems. blah blah blah blah.

Personally, I would be highly suspect of anyone that misstates a posting on a
discussion group in order to make themselves look better (show me my post
that says "never ever" you low life liar), cant name the person he is
TRASHING because he is a pansy (Miss Larry has been called that on here
before... i looked), ALWAYS uses bound forms, no 3rd party ActiveX controls
like treeviews and menus and grid controls, that are superior to controls
distributed with Access, that do not use bound forms to retrieve and display
information, and will warned you of something you were already made aware of,
not storing pictures in the DB itself, as though him telling you is better
than someone else telling you just so he can stroke his own ego.

The stupidity of the "expert" never ceases to amaze, because they always know
it all. After reading many of Miss Larry's posts, you can easily see that
she likes to show just how intelligent she really is as she rambles on about
this and that usually far above the level of the person asking the question.
The true sign of a weak person.
 
J

JB

Thank you DS and Larry
Definitely have the images stored in a folder out of the database.
Lots of very good stuff. going to take some time and give it a go.
So good to have you guys out there.
Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top