MS Access question

I would like to create a copy button, just select field and copy text.
would you advise me?
Snap1277.jpg
Hiroyuki TamuraField EngineerAsked:
Who is Participating?
 
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
 
COACHMAN99Commented:
copy to where? (clipboard?)
0
 
Hiroyuki TamuraField EngineerAuthor Commented:
yes
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
COACHMAN99Commented:
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText your source field (i.e. your text box)
clipboard.PutInClipboard
1
 
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
 
Hiroyuki TamuraField EngineerAuthor Commented:
thank you
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.