Solved

Adding .jpg instead of .bmp

Posted on 2011-02-17
9
452 Views
Last Modified: 2013-11-05
I have a basic application that is using and OLE Object to display photos on a form.  I want to upload .jpg but it will only allow me to upload .bmp

On the click of the add button a browse window opens to find the photo on my computer, I select it and press ok.  If I selected a .bmp then the photo gets attached to the record, if I choose .jpg and press ok it stays blank.

I commented out the code to only allow .bmp and just left "all files" uncommented.  HELP!

(screenshot of GUI)

In the table the field is called:

olePhoto and the data type is: OLE Object

This is the code:

Private Sub btn_add_Click()
  Dim fd As FileDialog
 
  Set fd = FileDialog(msoFileDialogFilePicker)
 
    With fd
      .AllowMultiSelect = False
      .Filters.Clear
      .Filters.Add "All Files", "*.*"
      '.Filters.Add "Bitmap Files", "*.bmp"
      If .Show Then
        olePhoto.SourceDoc = .SelectedItems(1)
        olePhoto.action = acOLECreateLink
      End If
    End With



End Sub

Private Sub btn_close_Click()
  DoCmd.Close acForm, Me.Name, acSaveNo
End Sub


Private Sub btn_remove_Click()
    olePhoto = Null

End Sub  
ee-photo.jpg
0
Comment
Question by:gcgcit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 

Author Comment

by:gcgcit
ID: 34918845
capricorn1: any ideas?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 34918979
You may not want to hear this but...

Then don't use OLE fields.
;-)

You can "Link" to the file: (see attached sample db.)

Or use a program like this:
http://www.ammara.com/dbpix/access.html


Or use the new attachment dataype in Access 2007 and newer.

JeffCoachman
Access-BasicLinkFormReportImages.mdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34918994
"capricorn1: any ideas?"
...you can't really specify one specific expert to help you...
0
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 

Author Comment

by:gcgcit
ID: 34919197
boag2000: I think it's capricorn1's code that I was using... that's why I specified him. I'm happy to have help from anyone, I'll go check out what you suggest... thanks for the sample database... that always seems to expediate figuring out the solution!
0
 

Author Comment

by:gcgcit
ID: 34919769
boag2000: looked at your sample database, appears to be what I'd need.  I've moved all your code and controls over to my form, when I try to add a picture by clicking the "Find Image" button I get this error:

Compile error:
Internal error

It highlights this line of code from the function FileToOpen: Dim OFN As gFILE
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34920428
Did you copy the VBA Module over as well?
;-)

Jeff
0
 

Author Comment

by:gcgcit
ID: 34932636
Jeff: I took all your code from the VB Module and pasted it into my own module called modStandard
0
 

Author Closing Comment

by:gcgcit
ID: 34932724
I made a brand new module instead of including yours inside my existing one and it worked great! Thanks!!!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34957756
Success!

;-)

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question