?
Solved

Using the double click event to copy and paste

Posted on 2015-01-21
8
Medium Priority
?
301 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 120

Accepted Solution

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

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

end sub
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

755 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