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

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

MS Access question

I would like to create a copy button, just select field and copy text.
would you advise me?
Snap1277.jpg
0
Hiroyuki Tamura
Asked:
Hiroyuki Tamura
  • 5
  • 3
  • 2
  • +1
1 Solution
 
COACHMAN99Commented:
copy to where? (clipboard?)
0
 
Hiroyuki TamuraAuthor Commented:
yes
0
 
COACHMAN99Commented:
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText your source field (i.e. your text box)
clipboard.PutInClipboard
1
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Hiroyuki TamuraAuthor Commented:
I'm getting this error.
Snap1278.jpg
0
 
COACHMAN99Commented:
did you set a reference to the library?
0
 
COACHMAN99Commented:
For using MSForms.DataObject in your code you need library “Microsoft Forms 2.0 Object Library”

Some­times you won’t find the desired ref­er­ences in the list, say you won’t find “Microsoft Forms 2.0 Object Library” in the tool/reference list in that case you need to browse the FM20.DLL file from the system32
0
 
COACHMAN99Commented:
Also, I would not use 'copy' as your field name. try txtCopy or some other non-system / non-reserved word. - this isn't related to your error message, just a note :-)
0
 
Dale FyeCommented:
Why not simply use the built-in right click menu?
0
 
Gustav BrockCIOCommented:
It is much simpler. No reference is needed:
Private Sub ButtonCopyToClipboard_Click()

    Me!YourTextboxName.SetFocus
    Me!YourTextboxName.SelLength = Len(Me!YourTextboxName.Text)
    DoCmd.RunCommand acCmdCopy
    
End Sub

Open in new window

/gustav
0
 
Hiroyuki TamuraAuthor Commented:
thank you
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now