473,883 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Parent" or "Owning" Form of a "Sub-Form"

How does a "sub-form", i.e. one invoked by another form, determine anything
about the form which brought it into existence, i.e., I suppose,
instantiated it? I wanted to so something like this ...

MsgBox("called by " & Owner.Name)

.... but that throws a null reference exception. Parent.Name and
ParentForm.Name also throw null reference exceptions. Form1.Name works -
but that's not very flexible.

My MsgBox, above, is in the constructor of the "sub-form".

Thanks, Bob
Sep 18 '08 #1
3 1924
On Sep 18, 2:15*pm, "eBob.com" <eBob....@total lybogus.comwrot e:
How does a "sub-form", i.e. one invoked by another form, determine anything
about the form which brought it into existence, i.e., I suppose,
instantiated it? *I wanted to so something like this ...

MsgBox("called by " & Owner.Name)

... but that throws a null reference exception. *Parent.Name and
ParentForm.Name also throw null reference exceptions. *Form1.Name works-
but that's not very flexible.

My MsgBox, above, is in the constructor of the "sub-form".

Thanks, *Bob
If you want to show the message box from the constructor, you're most
likely going to need to pass in a reference to the creating from as a
parameter.

I wonder however if you mean you want to know what form showed the
"sub-form". In which case the message box should live in the "Show"
and "ShowDialog " method, but be warned it might only work if you use
the overloaded call that passes in the owning form.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Sep 18 '08 #2
If it is an MdiChild, the it can call MdiParent.Name. If as you suggest you
are just doing a ShowDialog type of call, then you could use a StackTrace
object.

"eBob.com" <eB******@total lybogus.comwrot e in message
news:uB******** ******@TK2MSFTN GP05.phx.gbl...
How does a "sub-form", i.e. one invoked by another form, determine
anything about the form which brought it into existence, i.e., I suppose,
instantiated it? I wanted to so something like this ...

MsgBox("called by " & Owner.Name)

... but that throws a null reference exception. Parent.Name and
ParentForm.Name also throw null reference exceptions. Form1.Name works -
but that's not very flexible.

My MsgBox, above, is in the constructor of the "sub-form".

Thanks, Bob
Sep 18 '08 #3
>"rowe_newsgrou ps" <ro********@yah oo.comwrote in message
news:95******* *************** ************@m4 5g2000hsb.googl egroups.com...
On Sep 18, 2:15 pm, "eBob.com" <eBob....@total lybogus.comwrot e:
>How does a "sub-form", i.e. one invoked by another form, determine
anything
about the form which brought it into existence, i.e., I suppose,
instantiated it? I wanted to so something like this ...

MsgBox("call ed by " & Owner.Name)

... but that throws a null reference exception. Parent.Name and
ParentForm.Nam e also throw null reference exceptions. Form1.Name works -
but that's not very flexible.

My MsgBox, above, is in the constructor of the "sub-form".

Thanks, Bob

If you want to show the message box from the constructor, you're most
likely going to need to pass in a reference to the creating from as a
parameter.

I wonder however if you mean you want to know what form showed the
"sub-form". In which case the message box should live in the "Show"
and "ShowDialog " method, but be warned it might only work if you use
the overloaded call that passes in the owning form.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Hi Seth,

What I am after is the name of the form which did the

Dim sform as new SomeForm

i.e. in SomeForm code I want to get the name of who New'ed me. Maybe the
same code will Show me maybe it won't. Maybe it already has maybe it never
will.

Although I ran into the problem in constructor code it seems to me that it
is a general problem. MsgBox has nothing to do with the problem, I was just
using it to experiment and to illustrate the problem. In general I would
say that it is a bad programming practice to try to get at any information
about your creator (unless it is explicitly passed). But I think that there
might be exceptions such as Location (which is what I was after).

What really makes me curious is what Parent, ParentForm, and Owner mean
since not a one of them means what I would have guessed.

Thanks, Bob
Sep 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9987
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when performing the validation check on the values that were entered into the form, I simply repost the form to perform the PHP validation. If any of the values that have been entered into the form are incorrect, I display a warning message on the screen...
5
4266
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the second form when it is called. Both forms are .htm files that call themselves when the submit button is press via the following command in each form: <form method="post" action="<?php $server?>">
12
6159
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have allready made the database with the neccesary tables, and I know how to connect to it ) but I really have no idea how I can transfer the data from the webform to
3
5657
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change to the appropriate mode and test the html form it gave me an 500 internel server error. I really need it to be done soon, I would not post here before I test it as much as I can,
4
2379
by: Andrew Williams | last post by:
Does anyone know of a way to quickly validate an HTML web form? I need to make sure that certain fields on my form actually contain data and are not submitted blank. I have tried using client-side Javascript validation which flags up when a field is empty but the form is still submitted. Here is the ASP code I am using to submit the form to an e- mail with CDONTS:
2
2190
by: bart plessers | last post by:
Hello, I have a form with some checkboxes, i.e. The default value of this checkbox is determined in a global file (config.asp), that is included in first line of the form, i.e. ShowFilenames = 1 The first time the form is displayed, the value of ShowFilenames should be
5
1797
by: David Cairns | last post by:
Hi can anyone help me i am new to asp and going mad, why would the following only display the last line in the email, i.e the history text. thanks David Cairns <%@ Language=VBScript %> <%
2
4086
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and Oranges. The user selects from a drop down menu, between 1-10 of each and clicks submit. The resulting page will display a NEW form, with rows and a list of fields for the amount of each items selected.
2
3093
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own words, their own definitions plus an example of how the word is used in practice. It'll be all client side with - cookies? to get persistence so that the words won't disappear on me each time the page is closed (which is what happened when I
12
2479
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" HTML----------- Form is ----> <form action="thanks.php" method="post" name="contact_form" id="contact_form"> Name -------> <input type="text" name="name" id="name" size="25"> Button sends code -----> <input type="button" value="Submit Form"
0
9779
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,...
0
10730
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 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...
1
10835
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10407
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7960
isladogs
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...
0
7114
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();...
0
5787
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...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.