Consulting

Results 1 to 4 of 4

Thread: Solved: Using a button to update a photo field

  1. #1
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    2
    Location

    Solved: Using a button to update a photo field

    I am building a database with inventory involved. I have a field in my table called Photo. I have on my form, a text box bound to the photo field. I have a image frame called Img1 in my form. All of this works great.
    The problem comes in now where I want to add a control button to the form that will allow the user to navigate to a new image to replace the existing image on that record. They have this in the Northwind sample database on the Employees form. I have tried to copy the code and place it in my form but it doesn't work. I also would like to have it open a default Images folder when the button is selected.
    This all I have so far.


    Private Sub Form_Current()
    Image1.Picture = Path1
    End Sub

    I am using Access 2003

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Buster, welcome to the Forum.
    I have posted a database that does what you want here
    http://forums.techguy.org/business-a...data-base.html
    The Browsing part of the code is in the Module called mod_FileUtilities and in the Function called Function dbc_OpenFile

  3. #3
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    2
    Location
    Thank You OBP for your help.
    I went and got the database and part of it does exactly what I need.
    The problem is my VBA coding and so I am still working on trying to get the module to compile.
    Right now I am getting the Compile error on the first line Type FileSelInfo saying "connot compile a user-defined type within an object module"
    I have been working with Access for several years but really haven't done any VBA coding

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Buster, sorry I forgot to explain that you need to set some VBA Editor Library References, go to the VBA Editor>Main Menu>Tools>References and ensure that the ones shown in the Excel sheet "References" in the Zip I attached are ticked.
    The one that is showing the details on the excel sheet is the one giving you the problem, if you don't want to know the photo's File name (you already get the full path) then you can delete this part of the code -
    Set fs = CreateObject("Scripting.FileSystemObject")
    and
    Me.Document_Name = fs.GetFileName(Me.Document_Location)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •