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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JPG size in a OLE Field

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to include 4,000 jpg files in a OLE field but a 50 kb file in JPG is stored 500 kb in access database.

Im looking for a VBA program to clean the field


thanks
 
That is quite tricky, & yet you would think it should be very simple. The reason for size increase is because jpg's are stored as bmp's within an access database. Therefore it is much more efficient to store the data externally & creat a table with the path to the file in it...The following code is how we accomplished this. Paired with this, you need a form, containing an object control, a command button & a text field for the path...


Option Compare Database
Option Explicit
Private Sub Form_Current()
On Error GoTo Err_Form_current
Dim S_FILENAME As String
If Not IsNull(Me![A_IMAGE_PATH]) Then
S_FILENAME = Me![A_IMAGE_PATH]
With Me.Imagephoto
.Picture = S_FILENAME
.PictureType = "linked"
End With
RunCommand acCmdSaveRecord
Me.Refresh
End If
If IsNull(Me!A_IMAGE_PATH.Value) Or _
Me!A_IMAGE_PATH.Value = "" Then
'MsgBox "No picture available for this asset"
Me!Imagephoto.Picture = "c:\LandManagement2001\lul\template\norton.jpg"
End If
'DisplayImage Forms![photoselection_waste]![FPhotos_Waste]!
, S_FILENAME
Exit_Form_Current:
Exit Sub
Err_Form_current:
Resume Exit_Form_Current
End Sub

Private Sub OpenBtn_Click()
On Error GoTo Err_OpenFileBtn_Click
Dim S_FILENAME As String
Dim S_INITIALDIR As String
Dim S_COUNTER As Integer
Dim S_POINTER As Integer
S_POINTER = 0
' Step thro the path to determine the directory
If Not IsNull(Me![A_IMAGE_PATH]) Then
For S_COUNTER = 1 To Len(Me![A_IMAGE_PATH]) Step 1
If InStr(S_COUNTER, Me![A_IMAGE_PATH], "\", 0) = S_COUNTER Then
S_POINTER = S_COUNTER
End If
Next S_COUNTER
S_INITIALDIR = Left(Me![A_IMAGE_PATH], S_POINTER)
End If
' Call the common open file dialog to find a file
S_FILENAME = GetOpenFile(IIf(IsNull(S_INITIALDIR), "C:\", S_INITIALDIR))
' Set the field to the return value
If S_FILENAME <> &quot;&quot; Or Not IsNull(S_FILENAME) Then
Me![A_IMAGE_PATH] = S_FILENAME
With Me.Imagephoto
.Picture = S_FILENAME
.PictureType = &quot;linked&quot;
End With
RunCommand acCmdSaveRecord
Me.Refresh
End If
If IsNull(S_FILENAME) Then
S_FILENAME = &quot;&quot;
End If
'DisplayImage Forms![photoselection_waste]![FPhotos_Waste]!
, S_FILENAME
Exit_OpenFileBtn_Click:
Exit Sub
Err_OpenFileBtn_Click:
Resume Exit_OpenFileBtn_Click
End Sub
 
4.000 files in a folder will be quite difficult to maintain. If you want to integrate all these files into an ACCESS table you should consider using the Graphics! with ACCESS wizard (We integrated it in several different applications and it works GREAT!
 
I've got a field with a path and file name. I've used your example (thanks) to try and display this file (a jpeg). It doesnt work though! What control do I need to use? I used a bound object frame but I think this is wrong. I dont seem to have an &quot;Object Control&quot;.

As far as I can see the first sub will do what I want but what about the sub for the button. What is this supposed to do? When I click on the button Access just complains that &quot;GetOpenFile()&quot; is not defined. Is this a standard Access function?

Any help with this would be great, or if anyone knows of another method....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top