473,624 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting data from a field in another form

When i load a form (frmcontract) in the program i write i can load a contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure ) by pressing a button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcon tract.cbocontra ct.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?
Nov 21 '05 #1
3 1679
RBirney,

You can do it in VBNet as well, however it is not good OOP programming. You
make your form classes completly dependable from each other.

Better is to share your data in a whatever global class.
Sample
\\\
Public Class MyData
Public Shared myfield as string
End Class
///

Now you can use myfield everywhere in your project as
MyData.myfield

(This is a the most simple approach just to show you how it goes)

I hope this helps?

Cor
"RBirney" <RB*****@discus sions.microsoft .com>
When i load a form (frmcontract) in the program i write i can load a
contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure ) by pressing a
button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcon tract.cbocontra ct.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?

Nov 21 '05 #2
RBirney wrote:
When i load a form (frmcontract) in the program i write i can load a contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure ) by pressing a button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcon tract.cbocontra ct.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?


Is frmcontract visible to your frmexpenditure? IOW, is that a global
variable? If not, then frmexpenditure doesn't know that variable and the
code doesn't work. Now if you always call frmexpenditure only from
frmcontract, you could try me.parent.cboco ntract.text, presuming you
called the form as follows from frmcontract:

dim frmExpenditure as new clsExpenditure( ) 'I always call my form
clsSomething so I can call the referring vars frmSomething
frmExpenditure. showdialog(me)

or something similar.

Another way could be to define a public var in your frmexpenditure like
Dim cContract as String()

Then in frmContract do something like:
dim frmExpenditure as new clsExpenditure( )
frmExpenditure. cContract="what ever"
frmExpenditure. showdialog(me)

Then you'd have a var cContract available in your Expenditure form.

Rinze van Huizen
Nov 21 '05 #3
"Cor Ligthert" <no************ @planet.nl> schrieb:
Better is to share your data in a whatever global class.
Sample
\\\
Public Class MyData
Public Shared myfield as string
End Class
///

Now you can use myfield everywhere in your project as
MyData.myfield

(This is a the most simple approach just to show you how it goes)


Yep. Notice that by using this approach the same field will be shared
between all instances of 'MyData'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4

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

Similar topics

10
3697
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one firstname/lastname/telephone box - when the user clicks the add button, I read the values from the form fields and record them into a hidden text input field. This part works because during debugging, I have converted the <input type=hidden> into a <input type=text>...
2
4132
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5 Groups - call them A to E. I'd like to generate a further automatic reference number based on something like Group/Unique ID so when I create a new record Access creates the Unique ID & I then enter in the group and then Access combines the two...
15
7965
by: U N Me | last post by:
I have a continuous form that lists records from a query. One of the columns is an amount field, In the footer of the form I place a text box that displays the total (sum) of the amount. The data in the form is linked from a one-to-many table relationship. In this instance, I really can't sum the value from the one's table since if there were 3 records in the many table for a record id, the value would be summed 3 times. IOW, I may be...
11
12471
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this with a query but don't know what the criteria needs to be. Any help would be appreciated, Thanks
2
12547
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser <form action="display.aspx" method="post" target="_blank"> will submit the form data and open display.asp in a new browser
4
2255
by: Cerebral Believer | last post by:
Hi I need help! Forgive me I am a PHP newbie. I have a small script that enables me to send a form from an HTML page. I want to use the HTML formatted form because the design of my website is complex, and I don't want to have to mess around with formatting a page using HTML within php. So basically the "action" of the HTML page sends the form to "ProcReg.php". This is the code: <?php /* Script name: ProcReg.php
2
6103
by: shadowman | last post by:
So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and multipart/form-data). And for POST method, it has to be able to get the exact bit-for-bit accurate contents of the POST body. Now here's the problem: I'm stuck with POST multipart/form-data. The $GLOBALS only works with application/x-www-form-url-encoded. It...
2
4442
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for statistical purposes. I've been using Here's the situation: I have two main tables:
2
5585
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
0
8240
marktang
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...
0
8175
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
8680
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
8625
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
8336
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
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5565
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
4082
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
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.