473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference the calling form.

Is there a way to reference a calling form and pass an object to it?

This is what I'm trying to do:

Form A creates new instance of Form B and then calls it modal.
Form B creates a new instance of PersonalInfo class, makes a call to the db
and fills that class

Here's the tricky part:

I now want to pass the PersonalInfo object to the calling form (Form A) so
it can display this retrieved information.
I was thinking it would be something like: FormB.ParentFor m.PersonalInfoO bj
= FormA.PersonalI nfoObj

but this doesn't seem to work.

Thanks in advance,

Bill
Nov 21 '05 #1
4 1675
Sorry, that should be:

I was thinking it would be something like:
FormB.ParentFor m.PersonalInfoO bj = FormB.PersonalI nfoObj

Nov 21 '05 #2
Hi, William Oliveri
How about doing something like this?

'Inside FormA
With New FormB
.Owner = Me
.ShowDialog()
End With

'Inside FormB
CType(Me.Owner, FormA).Button1. Text = "Hello World"

Hope that helps.

From,
Hon Yuen, Ng
Nov 21 '05 #3
William,

Although I would not do that do I think that what you ask will be possible.

In formA
\\\
dim formB as frmB
frmB.showdialog
dim b as dataset = frmB.a
frmB.Dispose
///
In formB
\\\
Public a as new dataset
///

Your problem will probably be, that the GC has more problems than needed,
because dataset a in frmB will only be garbaged when it is not used anymore
in frmA.

Therefore quickly typed something as
\\\
dim formB as frmB
dim a as new dataset
frmB.a = a
frmB.Dispose
///
And than in frmB
\\\
public a as dataset
///
Has my preference

Just my idea

Cor


Nov 21 '05 #4
"William Oliveri" <wu**@bigvalley .net> schrieb:
Is there a way to reference a calling form and pass an object to it?


What you need in 'Form2' is a reference to your instance of 'Form1'. You
can pass the reference to 'Form1' in a property when showing 'Form2' from
'Form1':

Code for 'Form1':

\\\
Dim f As New Form2()
f.Form1 = Me
f.Show()
///

Code for 'Form2':

\\\
Private m_Form1 As Form1

Public Property Form1() As Form1
Get
Return m_Form1
End Get
Set(ByVal Value As Form1)
m_Form1 = Value
End Set
End Property
///

You can access 'Form1''s properties inside 'Form2' with 'Me.Form1', for
example, 'Me.Form1.Butto n1.Text = "Bla"'.

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainf orm&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5

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

Similar topics

12
11976
by: Bill Todd | last post by:
Form B needs to call a public method of Form A. How can form B get a reference to the instance of Form A using its name or any other method? Is there a collection of form instances that can be searched? -- Bill
3
2053
by: Giovanni Bassi | last post by:
Hello all, I have prepared a simple procedure to open forms only once. Here it is: -//- Private Sub OpenChildForm(ByRef objFormToOpen As System.Windows.Forms.Form, ByVal TypeToCreate As String)
3
2106
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening when I pass a class as a parameter to a Windows Form. Basically, I have a class that has several fields, two of these fields are an instance of an inner class, the rest are basic value types (bool's in this case). I have a windows form, the...
0
861
by: guy | last post by:
I have an application that references another assembly and calls methods in it - fine so far however one of the methods i call takes a Form from of the calling assembly as a parameter(actually 'Me'). it then uses this to create an instance of any other form in the calling assembly the problem is that this causes a security exception i cant reference the calling assembly from the called assembly as the
1
2020
by: Mike H | last post by:
I can't seem to figure out the right thing to search on, so I thought I'd just provide an example and see if someone can point me to some tips. What I have is an Automation Server that has a method that will start another automation server. These Activex automation servers that it talks to require a specific interface that the calling server uses to manage the child active x automation servers. This is all part of an application...
9
2449
by: Jack | last post by:
If I don't specify "ref" in the argument list when passing an array to the callee, I am passing the array (reference) by value. But this makes me confused because it actually means a "reference" of a "reference"??As I pass the array by value, the callee can change that array. However,when I use ref, the callee and caller point to two different arrays. So could anyone please explain the 2 different situations?
11
7036
by: thatguyNYC | last post by:
This is a complicated one... I have a modal form that lets the user preview some text, then either click Submit or Close. This form is called from several other forms. What I would like, since Access can't return a value from a form, is to set (from the modal form) a hidden checkbox on the calling form, which would show which button the user pressed on the modal form. My problem is this -- how can I pass the name of the calling form...
9
2897
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I thought that I would be able to reference the textbox simply by placing the name of the form it is located on (class name) in front as follows... param1 = frmSteelPlates.txtJobNo.Text I am getting the following error when I debug the line to...
275
12404
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
9480
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
10324
Oralloy
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...
0
10147
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...
0
9949
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
7499
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
5380
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...
1
4050
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
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
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...

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.