Solved

MS Access question

Posted on 2016-10-06
11
73 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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
 
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 50

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 50

Expert Comment

by:Gustav Brock
ID: 41833779
You are welcome!

/gustav
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

685 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