Click to See Complete Forum and Search --> : How to retrieve picture from MS access
nigel_chong98
Aug 24th, 2000, 05:04 AM
I know how to retrieve words from MS access but what about pictures. E.g
Private Sub Command1_Click()
sName = Combo1.Text
Set RS = DB.OpenRecordset("SELECT * FROM tblmachine WHERE MachineName = '" & sName & "'", dbOpenDynaset)
Combo1 = "" & RS!MachineName
Text2 = "" & RS!MaxPower
Picture1 = ????
RS.Close
Combo1.SetFocus
end if
End Sub
What do i type in for picture1 in order to retrieve different picture of items from a table in MS access?
Thanks for the help!
kovan
Aug 24th, 2000, 07:06 AM
personally i would never store pictures right into the ACCESS DB for many different reasons... i can go on about them... but i wont
why dont you make a directory where the database is and calle it Pictures...
and in a table have a field called PicturePath
and load the pictures throu a table but getting it from the picture directory
nigel_chong98
Aug 24th, 2000, 08:02 AM
Can you show me some example on it? Like how should i name my field for picturepath - OLE or Text or what even.
And for the command line in my VB program, do i still name it - picture1 = RS! photo
Please advice.
kovan
Aug 24th, 2000, 08:12 AM
gonna try to make this short n sweet (expect 2 pages)
we got a table called "Pictures"
in that table, we have a field called "PicPath" (set that to text) and a field called PicID (set that to autonumber)
in the same direcotry your .exe will be in
we have a DIRECOTRY called "Pictures" and all your photos in that direcotry
let say we have picture1.jpg, picture2.jpg ect
in the PICTURE TABLE, in the picpath field
we have "/picture1.jpg", "/picture2.jpg" as 2 records
now we want to display one of those pictures
let say we want to display first pic (and its ID should be 1)
so lets make sql
SQL = "SELECT * FROM Pictures WHERE PicID = 1"
set rs = db.openrecordset(sql)
'checking if there is a pic with that id
if not rs.eof then
'picture1 being a image control
picture1.picture = LoadPicture(app.path & rs!PicPath)
end if
if you have any questions let me know
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.