473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do I refer to the form a listbox is on?

5
Hello,

I've got some VBA code that's triggered on a listbox being doubleclicked. I'd like to also close the form that the listbox is on when that code is executed, but in the interests of portable code, I'd prefer not to specify the form name explicitly.

Is there a way I can refer to the form that the listbox is on so that I can close the form from within event code for the listbox? Or an even better way?

Many thanks in advance.
Oct 31 '06 #1
6 1562
pks00
280 Expert 100+
Hello,

I've got some VBA code that's triggered on a listbox being doubleclicked. I'd like to also close the form that the listbox is on when that code is executed, but in the interests of portable code, I'd prefer not to specify the form name explicitly.

Is there a way I can refer to the form that the listbox is on so that I can close the form from within event code for the listbox? Or an even better way?

Many thanks in advance.

On the dblclick event, when u open the form, cant u just close the form that opened it?
U are worried about portable code and not specifying form name explicitly
Well u can get round that by using Me.Name

DoCmd.Close acForm, Me.Name
Oct 31 '06 #2
NeoPa
32,556 Expert Mod 16PB
And if you're not within the form code (and this is something I wanted to know for years but found out recently) the object name for a form called 'frmMyForm' is 'Form_frmMyForm'.

It is similar for reports ('Report_rptBlahBlah')
Oct 31 '06 #3
jonman
5
On the dblclick event, when u open the form, cant u just close the form that opened it?
U are worried about portable code and not specifying form name explicitly
Well u can get round that by using Me.Name

DoCmd.Close acForm, Me.Name
Aha! I was under the mistaken assumption that the Me identifier referred to the listbox that the doubleclick event code was associated with. That's what I needed to know.


And if you're not within the form code (and this is something I wanted to know for years but found out recently) the object name for a form called 'frmMyForm' is 'Form_frmMyForm'.

It is similar for reports ('Report_rptBlahBlah')
That's worth knowing too - cheers to you both.
Oct 31 '06 #4
southoz
24
Aha! I was under the mistaken assumption that the Me identifier referred to the listbox that the doubleclick event code was associated with. That's what I needed to know.




That's worth knowing too - cheers to you both.

Good ay ,

I have a routine that opens an invisible form that gets data from a query into a list box (used for statements an invoices) , I use the form_open subroutine to do everything needed then just use the docmd.close to automaticly close the said form. works very well every time.

the docmd.close (without any extra commands) closes the form it was called from.
hope this is what u were after
southoz
Oct 31 '06 #5
ADezii
8,834 Expert 8TB
Hello,

I've got some VBA code that's triggered on a listbox being doubleclicked. I'd like to also close the form that the listbox is on when that code is executed, but in the interests of portable code, I'd prefer not to specify the form name explicitly.

Is there a way I can refer to the form that the listbox is on so that I can close the form from within event code for the listbox? Or an even better way?

Many thanks in advance.
'For the sake of keeping things generic
DoCmd.Close acForm, Me![ListBoxName].Parent.Name
Oct 31 '06 #6
NeoPa
32,556 Expert Mod 16PB
Me.Name (and even just Name on its own) works just as portably from within the module for the form.
The DoCmd.Close (without any extra parameters) closes the form it was called from.
Hope this is what u were after.
southoz
This seems a more portable / generic form (version) still.
I think I will (test and) use this one in future.
Oct 31 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JJ | last post by:
Hi All, When someone selects a value in a select on a form I want to show the same form with another select with certain values depending on first select. How can I do this? Should I keep...
6
by: octagon | last post by:
Hi, I have a form with various types of control such as txtbox, combo box, listbox, subform and check box I am trying hard to write a code for a check box after check the box all the control in...
1
by: bruce | last post by:
Hello, I have a small form that pops up when a user moves off the current record of a rather sizeable data entry form. The purpose of this form is to list warnings about various fields on the...
3
by: Brian Basquille | last post by:
Hey there all, Fairly easy question for a C# expert, i assume! Am still working on my Photo Album. On frmBrowsePhotos, i have a listBox (photosList) containing photoID's from a table in an...
4
by: Paradox | last post by:
Hey, I'm trying to figure out what situations call for the use of a derived form control such as: public class myListBox : System.Windows.Forms.ListBox and what situations call for the use...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
8
by: PAPutzback | last post by:
How do I keep the form up.
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
2
by: Rick | last post by:
First of all, is there a group more specific to WPF? I have a WPF form and I want to bind to a local member variable from the xaml. the code behind is like this: Partial Public Class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.