PDA

View Full Version : Capturing the Control + C event



sammy8932
06-02-2005, 09:39 AM
I need to capture the Control - C event and I'm not sure how to do it. I'm currently capturing the Return/Enter event. Is there a way to do this? My code is below.

Private Sub lstResults_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then 'Return/Enter key
lstResults_DblClick (False)
ElseIf 'this is where I need to capture the Control + C event to enable users to copy.
End If
End Sub

Once I've trapped this event, how can I allow the user to actually copy a specified variable?

I hope this is enough info to enable you to help me. If not I can try to better describe what I'm trying to do.

Thanks in advance.

xCav8r
06-02-2005, 05:51 PM
This is how you trap it:


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then 'Return/Enter key
lstResults_DblClick (False)
ElseIf KeyCode = vbKeyC And Shift = acCtrlMask Then
MsgBox "Ctrl+C pressed."
End If
End Sub


I'm not sure I understand what you're trying to do with it. Could you rephrase the question?

sammy8932
06-03-2005, 06:20 AM
Thanks xCav8r. I figured out how to trap it. I need to enable the user to be able to copy a variable (the phone number) out of the list box. I'm not sure how to do this. Below is the code that's used to fill the list box (PhoneNumberListBx):

ctl!PhoneNumberListBx.RowSource = "SELECT phone_id, phone_desc, FormatPhone(phone_number) FROM dbo_vwOrgPhone " _
& strWhere & " ORDER BY phone_desc;"

The phone_number is what I need to copy. Can you help me out on this? I appreciate your help....or anyone else that may have an idea how to do this.

Let me know if you have anymore questions.

Thanks.

xCav8r
06-03-2005, 10:48 PM
I don't know enough about what you're doing to comment on it, but I will nevertheless. ;)

Don't be offended by this suggestion: I use myself as a standard of comparison, and too often I am myopic in circumstances such as this. I think there might be more intuitive or apparent ways for users to grab a phone number from your listbox: a button that makes it obvious that the phone number is being copied to the clipboard or one that automatically inserts the phone number into a specific field, blah blah blah. I mention this in ignorance, but if it's something you haven't already considered, you should; and if it's something you've already considered, then ignore this paragraph altogether.

Still, if I could get a response to what I wrote above, I won't waste time describing how to do things that might not be necessary. I hope that makes sense.

sammy8932
06-06-2005, 06:34 AM
Thanks for the reply xCav8r. We considered/talked about inserting a button into the application that copies the phone number from the list box..and I'm really open to doing it anyway possible. As long as it works and is clear and easy for the user. Could you give me suggestions on the best way to do this. I'm not sure how to copy variables to the clipboard as I'm new to VBA (and all programming to be honest with you. I'm a recent graduate). I appreciate your help. Thank you very much.

xCav8r
06-06-2005, 08:18 AM
I don't know enough about what you're doing or who your users are to recommend an approach. If you want more advice from me in this regard, provide me with more information, and I'd be happy to offer advice. Generally, a button with some accompanying text explaining it is sufficient for most occasions. That seems more intuitive than a user clicking on a row in the listbox with multiple columns, hitting CTRL+C, and knowing that a phone number will be copied to the clipboard. At least, that seems to be the road that you're going down. Please correct me if I'm wrong.

The easiest way to get the phone number from the selection in the listbox is to bind the column for the phone number (do this in the properties dialog box), then in VBA do me.listbox.value whenever you want it (where listbox = the name that you've given to your listbox). If that doesn't make sense to you, let me know, and I'll provide more detail with examples.