I have a form in Access 2007 with many listbox controls on it. I want to run a certain routine that does something with the highlighted value in the listbox whenever any of them are double clicked. But it does not work.
I created a class that is supposed to handle this. Very simplified, and named "clsMyClass ", it looks like this: -
Private WithEvents lstThisBox As Access.ListBox
-
-
Public Property Set ThisList(ByRef lst As Access.ListBox)
-
Set lstThisBox = lst
-
End Property
-
-
Private Sub lstThisBox_DblClick(Cancel As Integer)
-
Call MyRoutine(lstThisBox)
-
End Sub
-
To demonstrate the problem, I created a form with a listbox named "List5" to use the class to handle it: -
Private clsListBox As clsMyClass
-
-
Private Sub Form_Load()
-
Set clsListBox = New clsMyClass
-
Set clsListBox.ThisList = Me.List5
-
End Sub
-
This does not work: when I double-click the List5 control, "MyRoutine" does not run. However, it does run if I define the DblClick event in the form -- even without anything in it, i.e.: -
Private Sub List5_DblClick(Cancel As Integer)
-
End Sub
-
Can anyone explain this? Is there any way around this? Thanks for your help on this ... --bobkohn 4 5964 ADezii 8,834
Recognized Expert Expert @bobkohn
Just subscribing, will look into this matter a little later. - Where does MyRoutine() reside and what is its Scope?
- Kindly post the Code for MyRoutine().
ADezii 8,834
Recognized Expert Expert
Access doesn't bother raising an Event for an Outside Object to Sink unless it thinks that it must. You must make sure that all Events you wish to Trap include the Text "[Event Procedure]" in the associated Property. The code listed below will work. Pay special attention to Code Block #1, Line #7. - 'In the Class Module clsMyClass
- Private WithEvents lstThisBox As Access.ListBox
-
-
Public Property Set ThisList(ByRef lst As Access.ListBox)
-
Set lstThisBox = lst
-
-
'Let's Trap the Double Click Event only
-
lst.OnDblClick = "[Event Procedure]"
-
End Property
-
-
Private Sub MyRoutine(lst As Access.ListBox)
-
MsgBox "ListCount Property of " & lst.Name & " = " & lst.ListCount & _
-
vbCrLf & vbCrLf & "Item Selected is: " & lst.ItemData(lst.ListIndex)
-
End Sub
- In Form's Declarations
- Private clsListBox As clsMyClass
- In the Form's Load() Event
- Private Sub Form_Load()
-
Set clsListBox = New clsMyClass
-
Set clsListBox.ThisList = Me.List1
-
End Sub
- Any questions, feel free to ask.
Thank you, ADezii, for figuring this out so quickly. I know where to ask for answers from now on ... --bobkohn ADezii 8,834
Recognized Expert Expert @bobkohn
You are quite welcome. Be advised that you can also set this Property for all List Boxes either manually or programmaticall y, as in: - Dim ctl As Control
-
-
For Each ctl In Me.Controls
-
If ctl.ControlType = acListBox Then
-
ctl.OnDblClick = "[Event Procedure]"
-
End If
-
Next
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shane Bishop |
last post by:
I've been fighting with the Page_Load event firing twice.
I looked through this user group and saw several other people having
similar problems.
There were various reasons for it:
AutoEventWireup="true" instead of AutoEventWireup="false"
Spyware software
And having your events all wired wrong
I had done everything to my machine, stripped it down to just have
..NET on it and I was still having this problem until...
|
by: Paul |
last post by:
Hi,
In a class i built, i fire an event when a field changes. In a webform that
has an instance of the class, the event (from the class) is fired and the
code is executed. However, my webpage does not reload (postback) after the
event fires. How do i get the webform to postback when the event fires
(after the code in the event is done executing)?
Thank you,
Paul
|
by: Larry Morris |
last post by:
The following code, pasted into a web form with a link button on it, will
cause the page_unload event to fire twice. If I remove the
response.redirect, the problem goes away :). I've got a work around, but I'm
curious how one is supposed to programmatically navigate between web pages
without the page_unload event firing twice.
Thanks,
Larry
|
by: RedGST |
last post by:
Hello,
Im somewhat new to asp.net, so bear with me.
I have created a form that has a Listbox along with 2 command buttons & a
few other non-important controls.
The command button is tied to the OnClick Event.
My problem is that when the command button is clicked, the Listbox
OnSelectedIndexChanged event gets fired before the command buttons OnClick
|
by: Gman |
last post by:
Hi,
I have created a usercontrol, a grid control essentially. Within it I
have a class: clsGridRecord. I have coded the events such that when a
user clicks on the grid, say, the events occur on the parent form. This
is fine.
The problem occurs when I want to raise an event for a user clicking on
one of the clsRecords which are on the grid. So I've placed:
Public Event GridRecordClicked(ByVal rec As clsGridRecord,
| |
by: tommaso.gastaldi |
last post by:
Hello,
A probably dumb question...
does anyone know hot to avoid that if one keep the mouse pressed on an
arrow of the numericUpDown it continues to fire events (it uses
evidently a timer) ?
I want 1 event for each click, and no timer activation. I have tried
using disable within the handler but does not work.
|
by: Paul_Madden via DotNetMonster.com |
last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be
displayed in different colours for easy reading.
Have set ScrollAlwaysVisible and HorizontalScrollbar to true.
I Anchor the listbox T, L, R, B on the parent form
The string items held within the listbox are quite big, much longer than
could be displayed within the Listbox display area.
|
by: pkiddie |
last post by:
Hi!
Im having real issues understanding delegates/events in .NET v1, and was
hoping someone could shed some light on where I'm not quite understanding.
I've got this piece of code in a base user control, which i've called
'PropertyPanel'. In it is the following code:
public delegate void EventHandler(object sender, EventArgs e);
public event EventHandler AppliedProperties;
|
by: superjacent |
last post by:
Hope someone can point me in the right direction.
When opening a form the 'click' event of the ListBox is invoked (run).
I thought the 'click' event of the ListBox is only invoked when
clicking it. I've looked all over the preceeding and other events on
the form and definitely do not invoke the ListBox 'Click' event.
What does happen during form initialisation or setup (load) is that the
rowsource, columnwidths, columncount etc are...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |