Link to home
Start Free TrialLog in
Avatar of Megin
Megin

asked on

Using the double click event to copy and paste

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!!!!!!
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

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
Also ... if you have any code in the Click event (?) ... that it's going to be very difficult to detect Double Click.

mx
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Megin
Megin

ASKER

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!!!!
So, what happens when you do Double Click ?

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

mx
<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
Avatar of Megin

ASKER

That worked perfectly! Thank you!!!

(And thanks to everyone else!!)
I thought you were having an issue detecting Double Click.