Full Version: Manually Firing an event - should be simple?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
SineNomine
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
I believe this would do the trick:

Call ButtonB_Click ()
radasys
Or change to event to Public and call it

|Public Sub ButtonB_Click ()
|
|
|End Sub

call it

Me.ButtonB_Click()
rkeifer
Try this

Call ListBoxA_DblClick
rkeifer
Sorry I think I made a slight mistake.
The double click eveny requires a "Cancel" parameter.
Try This

Call ListBoxA_DblClick(False)
RedLineSkis
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.