Solved

MS Access question

Posted on 2016-10-06
11
48 Views
Last Modified: 2016-10-07
I would like to create a copy button, just select field and copy text.
would you advise me?
Snap1277.jpg
0
Comment
Question by:Hiroyuki Tamura
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41832243
copy to where? (clipboard?)
0
 

Author Comment

by:Hiroyuki Tamura
ID: 41832316
yes
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41832327
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText your source field (i.e. your text box)
clipboard.PutInClipboard
1
 

Author Comment

by:Hiroyuki Tamura
ID: 41832392
I'm getting this error.
Snap1278.jpg
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41832410
did you set a reference to the library?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41832417
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
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41832424
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
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 41832679
Why not simply use the built-in right click menu?
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41833066
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
 

Author Closing Comment

by:Hiroyuki Tamura
ID: 41833760
thank you
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41833779
You are welcome!

/gustav
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now