MS Access: Manipulate the copied text from a control

I need to add some information to a control content when copied.

Say I have a control "MyCtrl" and the user copied the content -say "Abc"- I need then to add -say "123"-, so that when the user paste the information it will be pasted as "Abc123".

I think Access has no an event like on_Copy (That would be awesome), so I need some expert ideas to point me to the best way to do it.
Shadi SalehAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
USE & for concatenation

MyCtrl & "123"

sample-

"ABC"&"123"
0
John TsioumprisSoftware & Systems EngineerCommented:
Well if understood right you have a textbox and and you want to copy paste the content to another textbox and automatically append something...
While there is no Copy event you could use the clipboard functionality (API...i have some code somewhere but it would be easy to find it by googling it) ...so you copy the content..and when the destination textbox gets the focus (OnFocus) check the content of clipboard ...probably with some validation...and make the pasting...
0
Shadi SalehAuthor Commented:
Thanks @John Tsioumpris,

Indeed the paste will be done in another application.

I already googled and found this useful page, however, It suggest a way to do copy/paste through vba, but not, tell how to capture the copy event, and this is the most part I need to know about.

I thought of a custom copy button -this, I guess, should work- but what if user used the pop-menu copy.

apparently, I will need also to hide the pop-up menu, but what about ctrl+C?

It does not seem a simple issue that has a magic hidden solution.

I appreciate your suggestion, and I am looking for more expert ideas before I go this way.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

PatHartmanCommented:
This is an abstract issue and there's lots we don't know that might help us to come up with a solution that will always work. For example, if the string should contain these extra characters, why do you not store them?  Is the value you want to concatenate fixed or variable?

I don't think it makes sense to try to prevent people from using the copy and paste ribbon options or shortcut keys.  That just removes functionality that is useful in many situations.  You're going to have to rely on training if you cannot incorporate the extra characters permanently in your copy of the data.

To implement the copy/paste, I would either add a button or the double-click event of the control.  Your code would do the concatenation -- Me.txtMyControl & "123" and then copy it to the clip board.  I don't have the code but someone else may or you should be able to find it.  Then they still have to be relied on to paste into the correct receiving field.
0
Shadi SalehAuthor Commented:
I think I would use a custom copy button as the only way to copy the content the way the user want, keep the normal copy ways for the normal copy, and instruct the user accordingly.

I just thought that there was something like some webpages that append some stuff to the text you copy from their webpages.

Apparently, there is no such functionality in Access.
0
John TsioumprisSoftware & Systems EngineerCommented:
I was thinking again about your issue and this my idea of how i would do it...
On the 1 form/application the text that needs to be copied is only available through the DblClick event ...the user double clicks on the text box and the text is copied to the clipboard...for validation i would append in the start something like this : "Valid ToCopy:The Text you want to copy"
On the 2nd form/application the user again DblClicks on the destination textbox...the routine "reads" the clipboard...if the 1st part is  "Valid ToCopy:"...then the remaining text is pasted - manipulated...and clipboard gets cleared
0
Helen FeddemaCommented:
If the text to be added is constant, you could use an InputMask on the control with the added text pre-filled.
0
Shadi SalehAuthor Commented:
@Helen Feddema: Thanks, but it is variable.

@John Tsioumpris: Good, but we cannot alter the other application.

As I said before, I have no a problem in the copy process itself using a custom button or double click event.

What I thought, there might be an API function, a reference to another library or a tricky solution to catch the copy event itself regardless of the copy issuer (popup menu command, ribbon command, Ctrl+C or whatever ), then I won't need a custom button.

I tried mouse and keyboard events but they won't help in every case, and they have their implications.

Best Solution yet:

I tried the timer to watch the clipboard changes and to react accordingly.

Private Sub Form_Timer()
    
    Dim Clipboard_String As String
   
    Clipboard_String = ReadClipboard()
   
    If Clipboard_String = Me.Description Then
        
        CopyToClipboard (Me.Info & " - " & Me.Description)
        
    End If
    
End Sub

Open in new window


This was the best I could do yet, but I did not like the idea of the timer. I think something like interrupt would be better. Moreover, this can interfere with the normal copy/past operations.

I will wait some more time hoping to get a better solution, otherwise I would go with this solution if I could mitigate its shortcomings or may be stick to the copy button.

Thanks for all contribution.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shadi SalehAuthor Commented:
All other comments do not really come up with a solution.

My comment show my efforts to reach what I want to do, and show a code that work the best for my case.

Also, it shows the shortcomings of the all the solutions, and show the alternatives.
0
John TsioumprisSoftware & Systems EngineerCommented:
Well if you cannot alter the other application then i guess the only solution (a bit "dirty") it would be to use AutoIt...it won't be elegant but we a little effort it should work....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.