Adding Image with Command Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FyrJammer
    New Member
    • Feb 2007
    • 4

    Adding Image with Command Button

    I apologize if there is already a discussion about this, but I don't have a lot of time looking for it.
    I need to create a command button that opens explorer to search for images to add / put into / pastes to form / bound frame. It's a database for adding pictures to property inspection form. If anyone has or knows where I can find the codes for doing such a process please let me know. I really appreciate any help.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by FyrJammer
    I apologize if there is already a discussion about this, but I don't have a lot of time looking for it.
    I need to create a command button that opens explorer to search for images to add / put into / pastes to form / bound frame. It's a database for adding pictures to property inspection form. If anyone has or knows where I can find the codes for doing such a process please let me know. I really appreciate any help.
    Something like this will give you a get file window and return the full path to the file which can then be set to the frame.

    Code:
    Dim sFilename as String
    sFilename = Application.GetOpenFilename("Image Files (*.bmp),*.bmp, (*.tif),*.tif, (*.jpg),*.jpg")
    ' To Exit if Cancel was pressed
    If sFilename = "False" Then Exit Sub
    >
    >
    Mary

    Comment

    • FyrJammer
      New Member
      • Feb 2007
      • 4

      #3
      Originally posted by mmccarthy
      Something like this will give you a get file window and return the full path to the file which can then be set to the frame.

      Code:
      Dim sFilename as String
      sFilename = Application.GetOpenFilename("Image Files (*.bmp),*.bmp, (*.tif),*.tif, (*.jpg),*.jpg")
      ' To Exit if Cancel was pressed
      If sFilename = "False" Then Exit Sub
      >
      >
      Mary
      Thanks Mary, but is this code for my command button? I get a 'Method not recognized' error with the Application.Get OpenFilename part of the code. Attached you will find a part of the program I'm working on. The image box is where the image is going to be viewed (stored in database). I'm sorry for sounding too noobie, but I'm having a hard time figuring out how to make my button choose and save the image. The images will be relationed to specific addresses and I need to make each address have 2 images (Image1 and Image2).
      Is there a way you or anyone can help me with this? Much appreciated.

      Comment

      • FyrJammer
        New Member
        • Feb 2007
        • 4

        #4
        Thanks Mary, but is this code for my command button? I get a 'Method not recognized' error with the Application.Get OpenFilename part of the code. I have an image box where the image is going to be viewed (stored in database). I'm sorry for sounding too noobie, but I'm having a hard time figuring out how to make my button choose and save the image. Saving it as BLOB seems a little confusing to me.
        The images will be relationed to specific addresses and I need to make each address have 2 images (Image1 and Image2).
        Is there a way you or anyone can help me with this? Much appreciated and thanks in advance.

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          Originally posted by FyrJammer
          Thanks Mary, but is this code for my command button? I get a 'Method not recognized' error with the Application.Get OpenFilename part of the code. I have an image box where the image is going to be viewed (stored in database). I'm sorry for sounding too noobie, but I'm having a hard time figuring out how to make my button choose and save the image. Saving it as BLOB seems a little confusing to me.
          The images will be relationed to specific addresses and I need to make each address have 2 images (Image1 and Image2).
          Is there a way you or anyone can help me with this? Much appreciated and thanks in advance.
          You are probably missing a library for the Application.Get OpenFilename. However, it sounds like you want to store the images in the database which is not what the first question said. You can link to the images using an OLE Object datatype. Create a field and set to OLE Object and follow the wizard to set it up. Link, don't embed the files.

          Mary

          Comment

          • FyrJammer
            New Member
            • Feb 2007
            • 4

            #6
            Originally posted by mmccarthy
            You are probably missing a library for the Application.Get OpenFilename. However, it sounds like you want to store the images in the database which is not what the first question said. You can link to the images using an OLE Object datatype. Create a field and set to OLE Object and follow the wizard to set it up. Link, don't embed the files.

            Mary
            Oh, Ok. But yes, I do NEED to store the images to the database in a table because the whole database is going to be mobile via thumbdrive. My apologies for not specifying that earlier. And thanks.

            Comment

            • oanhhuynh
              New Member
              • Feb 2007
              • 2

              #7
              i have the same situation with you .i 've just known that we have OLE bound frame on form and OLE object in database .User could insert image by right-click this control but i'm not sure it add to the right id in database .So if you have find out the way to do ,please mail to me, [email removed]. Thanks!
              Last edited by MMcCarthy; Mar 9 '07, 02:17 AM. Reason: removed email address - against site rules

              Comment

              • svill
                New Member
                • Aug 2008
                • 1

                #8
                I am struggling quite alot here to set the picture of an OLE object. I do have some Visual Basic experience so please dont hesitate to hit me with the technical information.

                On my continous form i would like to set the OLE picture with a command button.
                Intentionally there will be an open-save dialog box. But just to the raw code here to do the core function. I have not read any articles on it but this code seems to work. It only adds the icon of a bitmap file, and not the actual picture in OLE.


                Me.PicturePrev. Class = "Paint.Pict ure"
                Me.PicturePrev. OLETypeAllowed = acOLEEither
                Me.PicturePrev. SourceDoc = "C:\1.bmp"
                Me.PicturePrev. Action = acOLECreateEmbe d
                Me.PicturePrev. SizeMode = acOLESizeZoom


                Please help

                Comment

                • FishVal
                  Recognized Expert Specialist
                  • Jun 2007
                  • 2656

                  #9
                  Hello, all.

                  The most efficient way to store files (documents, pictures etc) inside database is using BLOB. There is an article in bytes.com howto's section dealing with the issue.

                  Kind regards,
                  Fish

                  Comment

                  Working...