• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 80
  • 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 TamuraField EngineerAuthor 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Hiroyuki TamuraField EngineerAuthor 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 TamuraField EngineerAuthor Commented:
thank you
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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