Results 1 to 7 of 7
  1. #1
    mamba716 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4

    Error displaying image on form

    Hi all,



    I am currently creating a small database in Access 2003. It is similar to an employee or contact information database. I liked the feature on the sample Northwind database that allowed you to display an employee's image on the form next to their information, so I tried to replicate it. Here is my issue:

    I copied and pasted all of the VBA code, then went through the form and added the image frame, text box, command buttons, and error message, then added [Event Procedure] in control properties where appropriate, made sure the references in Visual Basic matched up, changed the images to .bmp format... basically everything I could think of to make the image feature identical to the one in Northwind. All of the code compiled without error, but when I click the Add/Change button and select the image that I would like to display, the image frame is blank. The image path looks to be correct. I even reduced the file size incase the image was too large. Still nothing. I'm relatively new to Access and am not sure what else to do. Anyone have any ideas of how I can fix this?
    I'd appreciate any insights!!

    Thanks )

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about posting your getFileName() procedure complete. Start with Sub and end with End Sub. That is where the selected picture is being displayed.

  3. #3
    mamba716 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4
    Code:
    Sub getFileName()
    ' Displays the Office File Open dialog to choose a file name
    ' for the current employee record. If the user selects a file
    ' display it in the image control.
       Dim fileName As String
       Dim result As Integer
       With Application.FileDialog(msoFileDialogFilePicker)
          .Title = "Select Panelist Picture"
          .Filters.Add "All Files", "*.*"
          .Filters.Add "JPEGs", "*.jpg"
          .Filters.Add "Bitmaps", "*.bmp"
          .FilterIndex = 3
          .AllowMultiSelect = False
          .InitialFileName = CurrentProject.Path
          result = .Show
          If (result <> 0) Then
             fileName = Trim(.SelectedItems.Item(1))
             Me![ImagePath].Visible = True
             Me![ImagePath].SetFocus
             Me![ImagePath].Text = fileName
             Me![FirstName].SetFocus
             Me![ImagePath].Visible = False
          End If
       End With
    End Sub

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you single stepped the code in the Northwind sample? Put a breakpoint on the With Application.FileDialog(msoFileDialogFilePicker) and F8 through the code and you will se that a lot is happening beyond that procedure. All of that code would need to be included in your db for it to work the same.

  5. #5
    mamba716 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4
    I just stepped through the procedure and all looks the same on both. Just to see, I tried adding one of my images to the employee form in the Northwind database and it didn't work.. I think there just might be a problem with my images or the directory they are in... I'm going to investigate...

  6. #6
    mamba716 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4
    Turns out there was a problem with my images... I changed the format and now everything works fine. Thanks for your help!

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Outstanding! Thanks for posting back with your success. Is this thread ready for the "Solved" thread tool?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filename displaying with image
    By Rob Parker in forum Forms
    Replies: 2
    Last Post: 01-13-2010, 05:05 PM
  2. Displaying form fields
    By sakthivels in forum Forms
    Replies: 5
    Last Post: 05-25-2009, 07:52 AM
  3. Displaying records from a form
    By ceb39 in forum Access
    Replies: 5
    Last Post: 04-03-2009, 12:36 PM
  4. Show a new image per record in a form
    By Bert Colourama in forum Forms
    Replies: 0
    Last Post: 09-25-2008, 05:22 AM
  5. Displaying a PDF in a Form
    By Chaz in forum Forms
    Replies: 0
    Last Post: 08-07-2006, 03:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums