Solved

Using the double click event to copy and paste

Posted on 2015-01-21
8
218 Views
Last Modified: 2015-01-22
My question is about using the double click event in with a list box.

I want the user to be able to double click on the item in a listbox and have the text from that item copied and then pasted into a text box.

It seems like this should be really simple, but I am having a hard time working out how to code it.

Would it just be a matter of something like: on double click, with item selected, copy string in column 2, then paste that text into txtbox 1?

Also, the listbox is multisimple select. Will that be a problem? I am trying to avoid changing that.

Just looking for a little guidance to get this going.


Thank you!!!!!!
0
Comment
Question by:Megin
8 Comments
 
LVL 75
ID: 40563350
Just curious ... why not single click?
Double clicking on a List Box is a bit unusual ...
And with MultiSelect Simple ... if user changes mind ... just click again (off) and remove text from text box.

mx
0
 
LVL 75
ID: 40563352
Also ... if you have any code in the Click event (?) ... that it's going to be very difficult to detect Double Click.

mx
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40563383
private sub list1_DblClick(Cancel As Integer)

me.textbox1=me.list1.column(1)

end sub
0
 

Author Comment

by:Megin
ID: 40563387
Right now the list box is populated with a list of records that the user has entered in past reports. The form that the list box is on is for the user to create reports. If the user wants to use a record from an old report in his/her new report, they select it from the list box, click a button, and it is added to the new report. If they want to add many old records to their new report, they just select multiple items before they click the button. It makes it quick and easy if their report rarely changes.

I just want to clone the record so that changes can be made to it in order to make a new record without changing the old one.

Ideally, double clicking on the item would just copy the text to a text box so that the record can be altered. For example, if the record is something long and wordy, has the name of the month in it, and has to be reported every month, I want the user to be able to double click on the record to copy and paste the text into a box, and then change the name of the month.      "Blah blah blah blah blah Janauary blah blah blah blah" becomes "Blah blah blah blah blah February blah blah blah blah"

The reason for the double click was to differentiate it from just selecting items. I thought about using the select option to do this, but then I can't use the multiselect simple setting (I only want the user to edit one item at a time).


If you have any better ideas for doing that, I am all ears.

Thank you!!!!
0
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.

 
LVL 75
ID: 40563406
So, what happens when you do Double Click ?

Seems I recall an issue detecting DC with a multi select list box ... not sure.

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40563409
<No Points wanted>

double click on the item in a listbox and have the text from that item copied and then pasted into a text box.
Also, the listbox is multisimple select
So if the user selects more than one item, you are forcing them to double-click each one?

Typically the user will select all the needed values, ...Then you would use code to gather all of the selected items, then do anything you want with them. (Display them horizontally, Vertically, Or put them all or individually in textboxes.
For example; by clicking a "Add values to textbox" button...
Code to collect all the selected could be something roughly like this:
Dim frm As Form, 
Dim ctl As Control
Dim varItem As Variant
Dim strSelItems As String
Set frm = Form!YourForm
    Set ctl = frm!YourMultiSelectListbox
    For Each varItem In ctl.ItemsSelected
        strSQL = strSQL & ctl.ItemData(varItem) & ", "
    Next varItem

Open in new window

...modified from:
http://access.mvps.org/access/forms/frm0007.htm

Perhaps I am missing something here though,
...I am sure Joe can get you sorted.
;-)

JeffCoachman
0
 

Author Closing Comment

by:Megin
ID: 40564711
That worked perfectly! Thank you!!!

(And thanks to everyone else!!)
0
 
LVL 75
ID: 40564721
I thought you were having an issue detecting Double Click.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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