Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures - without bloating 1

Status
Not open for further replies.

MikiH

Programmer
Sep 25, 2002
78
GB
Hello all

I'm trying to get a picture in a database so I can see on my form without bloating the database. This is what I have:

1st I have a folder called photos
2nd a table with one record, this being the path of the
folder (save people going into the code to change it)
3rd a frame (frame208) which asks "have photo yes / no"
4th a image frame to put the picture on the form

i've written the code below and call it in the afterupdate event of the frame and the on current event of the form.

the problem is that it loads all the pictures and not just the one I want?

Any ideas

Thanks
Mick




Private Sub loadpic()
On Error GoTo Err_loadpic

'check not a new record car not null
If Me![CARno] <> 0 Then

Dim strpath As String
Dim strfilename As String
Dim strlink As String

' get path from photolink table
strpath = DLookup("[photolink]", "[TBL photolink]")

' if check if picture is available
If Me![Frame208] = 1 Then ' 1 =yes

' get car number and consign it to path , set image frame to picture
strfilename = Me![CARno] & ".jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink

Else
' set picture to no picture picture
strfilename = "no pic.jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink

End If

End If

Exit_loadpic:
Exit Sub

Err_loadpic:

If Err.Number = 2220 Then
MsgBox "Photo was not found in the Photo directory!", vbInformation, "Photo not found."
Me![Frame208] = 2 ' 2= no photo

Else
MsgBox Err.Description

End If

Resume Exit_loadpic

End Sub
 
After long and painful hours of trying to find a solution to this problem of Access bloating when picture are stored. I have come to the conclusion that there is no way!
The best thing a person can do is do what you are doing store the pictures externally and call them as needed. Then only thing a can suggest is have the pictures so that the user views them on request not just on the form and when you scroll through the pictures change. This is because if you scroll fast Access will crash. I can not keep up to loading pictures rapidly. Have a button of something so when the use gets the record they want they can then view the picture. A little cumbersome but the most stable suggestion out there right now.


Brought to you By Nedaineum
|
|
The port to Geektron
 
How are ya MikiH . . . . .

There are two ways to store pictures in Access. [purple]Embedded[/purple] within Access (this is the bloating your talking about), or [blue]externally on the harddrive[/blue]. When stored externally, the pictures are [purple]linked[/purple] to Access ([blue]a pointer to the files is stored instead[/blue]).

See the [blue]Picture Type[/blue] property to set this.

Is the [blue]Image Frame[/blue] bound or unbound?

Calvin.gif
See Ya! . . . . . .
 
Linked or Embedded pictures still take up a lot of room when you use an OLE Object to store them in the DB
Stay Away from OLE Objects for just about everything they are what bloat the DB because of all the overhead store along with them.

use a image frame and store the image path in your database when you want to see the piture set the image frame piture property to the path and requry the image fram.

Code:
image1.Picture = "C:/temp/pic1.bmp"
image1.requery


Brought to you By Nedaineum
|
|
The port to Geektron
 
Thanks for the advice above but after a bit of investigation I've found out what was wrong with my db. I'd got the image frame set picture property set to a picture so it was loading 2 pictures. The only problem I have found with this code at the moment is that when you click the navigation buttons (standard form button) for a new record the current picture is still shown.


Anyway here is the code I've used and called from the afterupdate event of the check box / frame and the oncurrent event for the form.

Thanks
Mick



Private Sub loadpic()
On Error GoTo Err_loadpic

'check not a new record car not null
If Me![CARno] <> 0 Then

Dim strpath As String
Dim strfilename As String
Dim strlink As String

' get path from photolink table
strpath = DLookup("[photolink]", "[TBL photolink]")

' if check if picture is available
If Me![Frame208] = 1 Then ' 1 =yes

' get car number and consign it to path , set image frame to picture
strfilename = Me![CARno] & ".jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink

Else
' set picture to no picture picture
strfilename = "no pic.jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink

End If

End If

Exit_loadpic:
Exit Sub

Err_loadpic:

If Err.Number = 2220 Then
MsgBox "Photo was not found in the Photo directory!", vbInformation, "Photo not found."
Me![Frame208] = 2

Else
MsgBox Err.Description

End If

Resume Exit_loadpic

End Sub
 
put that function in the OnCurrent Event. That event fires each time you change records. So this way when you go from record to record and the function above will fire each time giving you the appearance of changing pictures.

Brought to you By Nedaineum
|
|
The port to Geektron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top