Solved linking jpeg outside of a database

TipsyWolf

Member
Local time
Today, 09:56
Joined
Mar 20, 2024
Messages
249
hello everyone !
so i have a db in a local storage and it has "data type" in a table - "attachment" where users upload pictures.

its only begging and now my db is around 150Mb. and every time a user opens this db - it should completely be downloaded and only then it opens up. sometimes it takes 6-8 seconds which is already pain under a nail if i can say so.
i checked - its 100Mb ethernet speed and sometimes it uses only 40% of its capacity, but still i think its not good way to store data in a long term.

is there a way to have a pic preview in a form , but store picture itself not in a db, but outside, like in root folder where ppl will move picture there and link them to specific ID.
maybe OLE object or hyperlink ? need your pro advices as usual guys.
 
If you have a table with a field containing a fully qualified file spec such as (using an arbitrary name) D:\SharedPix\John_Jones.JPG and you have an image control on your form, then in the Form_Current routine you can pick up the file spec from that field and load it to the image control's .Picture property. I think this is the simplest way to do this.
 
hello everyone !
so i have a db in a local storage and it has "data type" in a table - "attachment" where users upload pictures.

its only begging and now my db is around 150Mb. and every time a user opens this db - it should completely be downloaded and only then it opens up. sometimes it takes 6-8 seconds which is already pain under a nail if i can say so.
i checked - its 100Mb ethernet speed and sometimes it uses only 40% of its capacity, but still i think its not good way to store data in a long term.

is there a way to have a pic preview in a form , but store picture itself not in a db, but outside, like in root folder where ppl will move picture there and link them to specific ID.
maybe OLE object or hyperlink ? need your pro advices as usual guys.
Check this sample accdb from my website. It demonstrates a method of creating a report which loads externally stored images.
 
Check this sample accdb from my website. It demonstrates a method of creating a report which loads externally stored images.
should user to input manually a name of jpg so db can upload picture ? in this case it kinda might not work for me as ppl who will be using are total noob with PC. some of them at least.

is there an option to click, then select a pic through file browser and click OK. and it would be bloody awesome if db renames file according record ID a user uploading under
 
Last edited:
If you have a table with a field containing a fully qualified file spec such as (using an arbitrary name) D:\SharedPix\John_Jones.JPG and you have an image control on your form, then in the Form_Current routine you can pick up the file spec from that field and load it to the image control's .Picture property. I think this is the simplest way to do this.
i couldn't replicate what u suggested me.
could u please upload some simple demo ? much appreciated !
 
See if you can adapt this for your needs:
 
should user to intup manually a name of jpg so db can upload picture ? in this case it kinda might not work for me as ppl who will be using a total noob with PC. some of them at least.

is there an option to click, then select a pic through file browser and click OK. and it would be bloody awesome if db rename file according record ID user uploading under
I don't understand your reply exactly. But I think you're asking about attaching images to records. Colin already posted a link for his demo database which does that. If it does not rename the image, it could be modified to do that, I'm sure.
 
i have found a suitable way to store pics outside of db. It does work on template but it doesn't work when i move the code and buttons to my original db.
any idea why ?

1719214587643.png

Code:
Private Sub Command36_Click()
Dim fd As FileDialog
Dim i As Integer


Set fd = Application.FileDialog(msoFileDialogOpen)
    With fd
        .AllowMultiSelect = False
        
        'show only set of extension file in dialog
         .Filters.Clear
         .Filters.add "Image file", "*.jpeg;*.png;*.jpg;*.gif", 1
        
        If .Show = -1 Then
            For Each VtrselectItem In .SelectedItems
            For i = Len(VtrselectItem) To 1 Step -1
                If Mid(VtrselectItem, i, 1) = "." Then
                ext = Mid(VtrselectItem, i)
                
                Exit For
                End If
                
                Next i
                Me.FilePath = VtrselectItem
                
                ' if folder name doesnt exist then make new one
                On Error Resume Next
                MkDir "C:\Images\"
                On Error GoTo 0
                
                'if folder exist, copy image to distination folder
                'file name in the drive C:\
                FileCopy VtrselectItem, "C:\Images\" & Me.EmployeeId & "_" & Me.EmployeeName & "_" & Me.Position & ext
                Me.FilePath = "C:\Images\" & Me.EmployeeId & "_" & Me.EmployeeName & "_" & Me.Position & ext
                Me.PictureName = Me.EmployeeId & "_" & Me.EmployeeName & " _ " & Me.Position & ext
                
                Next VtrselectItem
                
                Else
                'display when no file is selected
                MsgBox "No File Selected.", vbInformation, ""
                
                
        
            End If
            Set fd = Nothing
 End With
 
End Sub
 
Need to set reference to Microsoft Office [version number] Object Library.
 
i dont get it.
i just looked at template's references and it has only these standard 5 checkboxes

in my original db i have exactly the same 5 checkboxes.
 
You need to start learning to debug your code.
As well as the error, you need to know what line that happens on.

Walk your code with F8 and breakpoints.
 
1719219041455.png


I MADE IT ! it WORKED !
thank u very much guys ! without your help it couldn't have been possible
 
Which template?

I opened George's in post 3 and as far as I can tell, it does not use FileDialog.
I am not seeing that library either with George's db.
It shows MS Office Object Library available.
However, when I open my db, I do see the other library.
 
Last edited:
Don't want the code. I wanted to see if get same behavior with References that the other db showed.
 

Users who are viewing this thread

Back
Top Bottom