Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

Adding .jpg instead of .bmp

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
gcgcit
Asked:
gcgcit
  • 5
  • 4
1 Solution
 
gcgcitAuthor Commented:
capricorn1: any ideas?
0
 
Jeffrey CoachmanCommented:
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
 
Jeffrey CoachmanCommented:
"capricorn1: any ideas?"
...you can't really specify one specific expert to help you...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
gcgcitAuthor Commented:
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
 
gcgcitAuthor Commented:
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
 
Jeffrey CoachmanCommented:
Did you copy the VBA Module over as well?
;-)

Jeff
0
 
gcgcitAuthor Commented:
Jeff: I took all your code from the VB Module and pasted it into my own module called modStandard
0
 
gcgcitAuthor Commented:
I made a brand new module instead of including yours inside my existing one and it worked great! Thanks!!!
0
 
Jeffrey CoachmanCommented:
Success!

;-)

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now