Image upload for user

Fides

Registered User.
Local time
Today, 13:08
Joined
Jul 17, 2012
Messages
23
Hello,

I want to give the user the ability to add 1 or more pictures to the record in the form. The user should be able to click a button then select a image file then the image should show in the form and saved in the database.

Hope someone can help.

Thanks. :)
 
Your best bet for image storage is to store your images outside of the Database and then when you want to view the image you would just change the .picture property of an image control. Are you familiar with using Visual Basic?
 
Yeah I figured storing pics outside of the db. But my VB skills are really bad. I usually copy paste code from websites like this one. Hahaha

Thanks in advance for the help! :)
 
I have made a quick db in Access 2007. There is a module that is not mine but is free to use as long as you keep the copyright information intact. As for the rest of the code on the forms it is pretty cut and dry. I hope that this helps.

Extract the zip folder directly to your C:\ drive for the pictures to display properly.

View attachment Pics.zip
 
Thanks for your efforts gbnz but that doesn't work on a 64 bits system. And it looks pretty complicated too. Is it that hard to have a simple image selection tool in a form?
 
Thanks for your efforts gbnz but that doesn't work on a 64 bits system. And it looks pretty complicated too. Is it that hard to have a simple image selection tool in a form?

I built the db with a 64bit system so I don't understand why it wouldn't work with that same kind of system?? What kind of an error are you receiving??
 
When I open the main form the error in the visual basic window says: Compile error: The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute.
 
Wow I have no idea what that is all about. It works perfectly on my computer Windows 7 64bit. I have even went so far as to compile the code for the db and it doesn't error either. Sorry I couldn't help you.
 
Okay, I got the 64bit error fixed, but now the 'Set' button doesn't work. I didn't change anything to that code so I would be surprised if it does work for you. When I click that button it does nothing. But when I empty the field and click it then it removes the location of the image-file from the database. Shouldn't it popup a window to ask for an image file to add?
Thanks!
 
If you could would you please upload the DB that you changed. I would like to see what is different.

thanks,
 
I hope you can find something. Thank you very much. :)
 

Attachments

Okay I went out and researched the Application.FileDialog function and came up with some new simplified code. Try this DB out and see if it works.
 

Attachments

It works fine. Now I'll have to integrate it in my current DB. Thanks again. :)
 
It works fine. Now I'll have to integrate it in my current DB. Thanks again. :)


One other thing and I hope this makes sense...and maybe another coder can jump and explain it better then I can.

When you type the code into another database and type the following

Code:
 Dim fDia as office.FileDialog

You will notice that "Office" is not in the dropdown list after typing "as"

The Reference is not installed to the object "Office".

The only way I know how to install it is to type the following:

Code:
 set fDia = Application.FileDialog(msoFileDialogFilePicker)

Once you type that Access will open a dialog and state that the Reference is not there and would you like to install it. Click yes and it will also install the Reference for the "Office" object.

Code:
 'declare variables
    Dim fDia As [COLOR=red]Office[/COLOR].FileDialog
    Dim varFile As Variant
 
    'remove the current file
    Me.Image = Null
 
 
    [COLOR=blue]Set fDia = Application.FileDialog(msoFileDialogFilePicker)[/COLOR]
 
    With fDia
 
        'Do not allow user to make multiple selections in dialog box '
        .AllowMultiSelect = False
        'Set the title of the dialog box.'
        .Title = "Please Select an Image..."
        'Clear out the current filters, and add our own.'
        .Filters.Clear
        .Filters.Add "Image JPG", "*.jpg"
        .Filters.Add "Image PNG", "*.png"
        .Filters.Add "Image BMP", "*.bmp"
        .Filters.Add "All Files", "*.*"
        'Set the initial folder
        .InitialFileName = "C:\Pics\"
 
        If .Show = True Then
            For Each varFile In .SelectedItems
                Me.Image = varFile
            Next
        Else
            MsgBox "Canceled"
        End If
    End With

Hope this helps and sorry for any confusion.
 
I not trying to undermine what you are trying to do but images rendering should automatic. What I mean by that is if you enter a record and using the a same naming convention between the image and the record - the image will be automatically be rendered.

The benefit is that if you look in the image directory you can identify each image with a record. Randomness means that you have to refer back to the database to know what the image relates to.

This may seen too anal but with 20,000 I had to use some sort rationale to manage the images. The secondary image file reference were allocated manually but again using the primary reference and appending characters to distinguish the file.

Simon
 
I think I can use this.

I have a form for inspections, the inspector fills out the form and then I want them to be able to attach pictures of their findings. I want them to grab pictures from their HD and attach them to the form. I want all pictures to be saved to a network folder, this way users don't have to keep the pictures on their HD and we don't have to worry about broken links.

How do I grab the pictures from location A and save them to location B???
 
Hi gbnz, I can't get Set fDia = Application.FileDialog(msoFileDialogFilePicker) to work. Any ideas on how? Thanks
 
Hi gbnz, I can't get Set fDia = Application.FileDialog(msoFileDialogFilePicker) to work. Any ideas on how? Thanks

I am sorry I need more information. What is not working? Does it error? Did you copy and paste the code? If so try typing it out and see if Access will ask to install the reference for it. Let me know and I will be happy to assist you.

Thanks
 
I tried typing it out and access enver asked me to install anything.

However I found a work around that seems to work, thanks

Const msoFileDialogFilePicker As Integer = 3
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Show
If fd.SelectedItems.Count > 0 Then
Source = fd.SelectedItems(1)
Else
End
End If
End With
 
Cool...there is always more than one way to get the job accomplished.
 

Users who are viewing this thread

Back
Top Bottom