By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,484 Members | 1,851 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,484 IT Pros & Developers. It's quick & easy.

Copy field contents using DblClick action

lwwhite
P: 16
(Access 2003) Here's what I want to do: enable users to double-click a field in a datasheet-view subform and thereby save the contents of that field to the Windows clipboard so that they can then paste it into another field. I tried to set it up as a DblClick event on the field with this syntax:

DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70

However, when I tested, I got a message that the Copy action wasn't available. So then I changed it to a KeyDown event, meaning users have to double-click THEN press a key to copy the data. This works, but I'd really like to copy with just a double-click.

What am I missing?
Dec 14 '06 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,186
I would guess that it only works when the field you want is the active control.
I never use macros so this is not an area I understand very well.
Dec 14 '06 #2

missinglinq
Expert 2.5K+
P: 3,532
The Copy Action wasn't available because you had no text selected to copy! This code sets the cursor to the beginning of the text box, selects all of the text and then carries out your copy action:

Expand|Select|Wrap|Line Numbers
  1. Private SubYourTextBoxName_DblClick(Cancel As Integer)
  2.     Me.YourTextBoxName.SelStart = 0
  3.     Me.YourTextBoxName.SelLength = Len(Me.YourTextBoxName.Value)
  4.     DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
  5. End Sub
  6.  
Tested in Access2000.
Dec 14 '06 #3

NeoPa
Expert Mod 15k+
P: 31,186
Thanks ML for covering my arse.
Good answer.
Dec 14 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.