UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Copy Value To Clipboard, Access 2016    
 
   
Bokenrosie
post Jan 15 2018, 12:13 PM
Post#1



Posts: 28
Joined: 15-January 18



I'd like to create a button on a form to copy some text to clipboard.

Background
I have contact database and I want to create an easy way to grab first name from the form and add text around it then copy it to clipboard so I can take that value outside of Access to paste in a website by hand.

Operation
Click on button and it creates a value in clipboard that says: "Dear [FirstName], Thank you for your interest in our products. We will be in touch with you shortly"

So click on that button on form then attach Macro (I think) that builds this combination of table value and text and loads the clipboard.

Already created the button but don't know what to load in the actions.

TIA for any suggests. Seems this was much easier to do in FileMaker.
Go to the top of the page
 
theDBguy
post Jan 15 2018, 12:17 PM
Post#2


Access Wiki and Forums Moderator
Posts: 73,269
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

Is the form bound to the table where the information you need is stored? If so, you can concatenate the current record data to your message. For example:

Dim strMessage As String

strMessage = "Dear " & Me.FirstName & ", Thank you..."

As for copying this value to the Clipboard, you can either use API or SendKeys (Ctrl + C).

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Bokenrosie
post Jan 15 2018, 12:38 PM
Post#3



Posts: 28
Joined: 15-January 18



Sorry for the NOOB question, does that mean I need to use VBA code to build this? Not expression builder in Access?
Go to the top of the page
 
theDBguy
post Jan 15 2018, 12:41 PM
Post#4


Access Wiki and Forums Moderator
Posts: 73,269
Joined: 19-June 07
From: SunnySandyEggo


Hi,

The expression builder is for creating a result to display in a Textbox. In this case, you will either use the Macro Builder or the Code Builder since you want to create "actions" to combine the data/value and then copy it to the clipboard.

Hope it makes sense...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
DanielPineault
post Jan 15 2018, 12:46 PM
Post#5


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



Take a look at http://access.mvps.org/access/api/api0049.htm and https://msdn.microsoft.com/en-us/VBA/access...o-the-clipboard

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
Bokenrosie
post Jan 15 2018, 12:51 PM
Post#6



Posts: 28
Joined: 15-January 18



Wow, so I'm in access and I hit create -> Macro which does not give me a Dim option (so I must be in wrong place)

then I try again with Create - Visual Basic (under Macro) which puts me in blank window and that looks like wrong place too.

I've done this a ton of times in Filemaker. It was super easy. I created a field for temp use and then used a set field = command to concatenate text and record values. Finally a "copy field" command to get the value.

Is there a similar construct in Access?

Or a "dummies version of what I'm supposed to be doing in your help above? Sorry I'm totally lost here.
Go to the top of the page
 
Bokenrosie
post Jan 15 2018, 02:10 PM
Post#7



Posts: 28
Joined: 15-January 18



Wow, feeling pretty lost here.

so I'm in access and I hit create -> Macro which does not give me a Dim option (so I must be in wrong place)

then I try again with Create - Visual Basic (under Macro) which puts me in blank window and that looks like wrong place too.

I've done this a ton of times in Filemaker. It was super easy. I created a field for temp use and then used a set field = command to concatenate text and record values. Finally a "copy field" command to get the value.

Is there a similar construct in Access?

Or a "dummies version of what I'm supposed to be doing in your help above? Sorry I'm totally lost here.

Thanks for any help to get me started on this.
Go to the top of the page
 
moke123
post Jan 15 2018, 02:23 PM
Post#8



Posts: 1,318
Joined: 26-December 12
From: Western Ma.,L.I.,N.Y.,Jupiter,Fl.



select event procedure in the drop down and then click the elipsys (...) that should put you in the vbe.
Attached File  p2.PNG ( 6.62K )Number of downloads: 0



if you have a textbox called MyText then you would have code along the lines of

CODE
Private Sub Command40_Click()
    Me.MyText.SetFocus
    Me.MyText.SelStart = 0
    Me.MyText.SelLength = Len(Me.MyText)
    DoCmd.RunCommand acCmdCopy
End Sub
Go to the top of the page
 
DanielPineault
post Jan 15 2018, 02:35 PM
Post#9


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



Just one addition to moke123's post, based on your original request (adding extra text to the control value), you'd need to do use the API to concatenate the control value with extra text, or use a hidden control to do it there and use it for the RunCommand.



--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
Bokenrosie
post Jan 15 2018, 02:42 PM
Post#10



Posts: 28
Joined: 15-January 18



It's working. I'm a bit stunned at how hard this is. But it's working.

Go to the top of the page
 
DanielPineault
post Jan 15 2018, 02:43 PM
Post#11


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



Take a look at the following sample database. to see how to concatenate extra text to a control's value and push all of it to the clipboard.





Attached File(s)
Attached File  Clipboard_Demo.zip ( 62.63K )Number of downloads: 16
 

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
DanielPineault
post Jan 15 2018, 02:46 PM
Post#12


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



QUOTE
It's working. I'm a bit stunned at how hard this is. But it's working.


Don't be discouraged, you're learning a new language. It is normal that certain aspects will seem difficult, others will be extremely easy.

Good luck. thumbup.gif



--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
Bokenrosie
post Jan 16 2018, 09:59 AM
Post#13



Posts: 28
Joined: 15-January 18



I don't suppose somebody could tell me why this fails?

Private Sub Image257_Click()
Dim myString As String
myString = "Dear " & Me.First_Name & " " & Me.Last_Name
myString.SetFocus
myString.SelStart = 0
myString.SelLength = Len(Me.myString)
DoCmd.RunCommand acCmdCopy
End Sub
Go to the top of the page
 
cheekybuddha
post Jan 16 2018, 10:17 AM
Post#14


UtterAccess VIP
Posts: 10,347
Joined: 6-December 03
From: Telegraph Hill


myString is a string variable, not a textbox control.

A string variable does not have properties like SelStart or SelLength, nor methods like SetFocus.

Use the API to get the value of myString in to the clipboard.

If you're not sure how to use the API, then ask.

It's really a case of copy and pasting the code (from the first link in Daniel's post #5) into a new module.

Then, in your sub using:
CODE
Private Sub Image257_Click()
Dim myString As String
myString = "Dear " & Me.First_Name & " " & Me.Last_Name
ClipBoard_SetText myString
End Sub


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
DanielPineault
post Jan 16 2018, 12:35 PM
Post#15


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



Look at the sample I supplied, it has everything you need. Sadly, DoCmd.RunCommand acCmdCopy won't work for your needs.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
Bokenrosie
post Jan 23 2018, 04:02 PM
Post#16



Posts: 28
Joined: 15-January 18



Daniel,

I'm back after completing the Lynda.com VBA class. It's a bit dated but helped.

Your attachment was a HUGE help. Thank you.

I'm still amazed at how many lines of code are in that module but I copied it over to my application and it all seems to work now.

Thanks, so much.
This post has been edited by Bokenrosie: Jan 23 2018, 04:54 PM
Go to the top of the page
 
DanielPineault
post Jan 24 2018, 01:39 PM
Post#17


UtterAccess VIP
Posts: 6,070
Joined: 30-June 11



thumbup.gif

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    25th September 2018 - 02:12 AM