Solved

Using the double click event to copy and paste

Posted on 2015-01-21
8
211 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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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
Comment Utility
private sub list1_DblClick(Cancel As Integer)

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

end sub
0
 

Author Comment

by:Megin
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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
Comment Utility
<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
Comment Utility
That worked perfectly! Thank you!!!

(And thanks to everyone else!!)
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
I thought you were having an issue detecting Double Click.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

763 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

9 Experts available now in Live!

Get 1:1 Help Now