SineNomine
Sep 15 2005, 03:24 AM
Hi Guys
I'm a bit of a novice with VBA (I'm much more used to C++/MFC); I've managed so far, but seem to have got a bit stuck with this:
I've got two controls on a form - ListBoxA and ButtonB. All I want to do is to cause the OnClick event of ButtonB to call the OnDoubleClick code of ListBoxA, assuming that the selection in the list box has already been made validly.
Mainly so I don't have to put the same code chunk in twice...
It sounds so simple. Here are the main two things I've tried:
|Private Sub ButtonB_Click ()
|
| Me.ListBoxA.OnDblClick ' => runtime errors about incorrect use of the OnDblClick property.
| Gosub List17_DblClick ' => Complains that 'List17_DblClick' is an undefined identifier or something
|
|End Sub
Can some kind person put me out of my misery?
Cheers
Alsitair
MrSiezen
Sep 15 2005, 03:32 AM
I believe this would do the trick:
Call ButtonB_Click ()
radasys
Sep 15 2005, 06:29 AM
Or change to event to Public and call it
|Public Sub ButtonB_Click ()
|
|
|End Sub
call it
Me.ButtonB_Click()
rkeifer
Sep 15 2005, 09:36 AM
Try this
Call ListBoxA_DblClick
rkeifer
Sep 15 2005, 09:40 AM
Sorry I think I made a slight mistake.
The double click eveny requires a "Cancel" parameter.
Try This
Call ListBoxA_DblClick(False)
RedLineSkis
Sep 15 2005, 09:58 AM
You could try and throw the code from the double click event into a function in a module and just call the function from the double click event and the onclick event. This way you only have one fuction to deal with and any form can use it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.