Results 1 to 6 of 6
  1. #1
    ali_sh is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    21

    Open attachment window in form by button


    Hello
    How can I create a button in form to open attachment window by clicking on it using macros or vba?
    Thanks in advance

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I have no idea what an attachment window is. Maybe you're wanting to open the file? The attachment is in a table field (not a good idea)? If so, is the attachment field part of the form's records?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ali_sh is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    21
    Quote Originally Posted by Micron View Post
    I have no idea what an attachment window is. Maybe you're wanting to open the file? The attachment is in a table field (not a good idea)? If so, is the attachment field part of the form's records?
    Thank you for your answer
    I mean this window:

    Click image for larger version. 

Name:	Untitled1.jpg 
Views:	10 
Size:	24.7 KB 
ID:	40151

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    this is supposed to work but does not for me (get error message "The command or action 'Manage Attachments' isn't available now". Perhaps it is an Access version problem. Focus IS set to the attachment field so I know that part works. You would have to substitute the name of your attachment field control name on the form and see what happens
    Code:
    Me("tblAttachment.CrosstabTest.FileData").SetFocus
    DoCmd.RunCommand acCmdManageAttachments
    I also tried what is supposed to replicate the double click event with SendKeys but that does nothing.
    That being said, experience Access developers would not store attachments in tables anyway, in favour of storing file paths to the files. Maybe you shouldn't either
    I might play with it some more, but no promises. Maybe the problem is that it's not something that can be done from a form that has an attachment field

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Cross post https://stackoverflow.com/questions/...form-by-button

    Code works for me.

    Me.attachmentcontrolname.SetFocus
    DoCmd.RunCommand acCmdManageAttachments
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by June7 View Post
    Code works for me.

    Me.attachmentcontrolname.SetFocus
    DoCmd.RunCommand acCmdManageAttachments
    Interesting. I get the error, as mentioned. You are using 2010 so maybe it IS a version thing.
    Note: Me.attachmentcontrolname.SetFocus also produced an error for me. That's why I posted
    Me("tblAttachment.CrosstabTest.FileData")
    Also, thanks for the cross post note. If the OP doesn't acknowledge the error of their ways, I usually add them to my ignore list because I have no desire to waste my time. However, you didn't post the usual link to what's wrong with that, so I will:

    ali_sh - if you have not already been asked to do so, please review
    https://www.excelguru.ca/content.php?184

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

Similar Threads

  1. Replies: 2
    Last Post: 06-04-2017, 08:29 PM
  2. Replies: 0
    Last Post: 03-30-2017, 03:20 PM
  3. Open an attachment using a command button
    By Eddy Sincere in forum Forms
    Replies: 3
    Last Post: 04-03-2015, 11:43 AM
  4. How to open form in a same window
    By sanchez in forum Forms
    Replies: 11
    Last Post: 08-27-2013, 03:53 AM
  5. Unable to open DB window on a Button click
    By ssashraf in forum Security
    Replies: 6
    Last Post: 12-12-2012, 12:39 PM

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