473,394 Members | 1,821 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,394 software developers and data experts.

Access data from another form.

Hi All,

There are two forms, when some click happen, it fires to set form2's
viable as enable.

The form2 is for user to input some text and then the data need to be
collected into form1's textbox.

I have created a function call as public, but I still can't use it in
form2.

Please advice. Thanks!

Best regards,
Boki.

Jul 10 '07 #1
5 2384
On Jul 10, 5:34 pm, Boki <bokit...@ms21.hinet.netwrote:
Hi All,

There are two forms, when some click happen, it fires to set form2's
viable as enable.

The form2 is for user to input some text and then the data need to be
collected into form1's textbox.

I have created a function call as public, but I still can't use it in
form2.

Please advice. Thanks!

Best regards,
Boki.
I saw a method is to create another copy of form.

ex:
private Form2 form2 = new Form2();

but I think seems not too reasonable, isn't it ?

Boki.

Jul 10 '07 #2
On Jul 10, 10:34 am, Boki <bokit...@ms21.hinet.netwrote:
There are two forms, when some click happen, it fires to set form2's
viable as enable.

The form2 is for user to input some text and then the data need to be
collected into form1's textbox.

I have created a function call as public, but I still can't use it in
form2.
Why not? What happens when you try? You'll need a reference to the
appropriate instance of form2 within form1, of course.

Jon

Jul 10 '07 #3
On Jul 10, 5:40 pm, "Jon Skeet [C# MVP]" <s...@pobox.comwrote:
On Jul 10, 10:34 am, Boki <bokit...@ms21.hinet.netwrote:
There are two forms, when some click happen, it fires to set form2's
viable as enable.
The form2 is for user to input some text and then the data need to be
collected into form1's textbox.
I have created a function call as public, but I still can't use it in
form2.

Why not? What happens when you try? You'll need a reference to the
appropriate instance of form2 within form1, of course.

Jon
Thanks, but I am not very understand here.

If we create another form, and then access to this form, why the
modified result also change the original form.... why not only the
copied form..
Boki.

Jul 10 '07 #4
It's not entirely obvious from your post, but I assume you want the text
from Form2 to become visible in Form1 without the user carrying out any
specific action, such as clicking a button that says "Fill Form1", or
something.

In that case, what you want, I guess, is to be able somewhere in code in
Form2 to be able to do something like:

Form1.FillTextBox(SomeString);

This means that you need a reference to Form1 in Form2. The easiest way of
doing this is to provide Form2 with a constructor that passes in a reference
to Form1. In Form1, you provide the FillTextBox() method.

So, in Form1 you can do:

Form Form2 = new Form(this);
Form2.Visible = true;
Form2.Show();

(or whatever)

In the Form2 constructor, you can store the reference to Form1 in an
instance variable:

Form Form1Ref;
....

public Form2(Form formoneref)
{
...
Form1Ref = formoneref;
...
}

Then in Form2 somewhere you can do:

Form1Ref.FillTextBox(MyForm2TextBox.Text);

The code above is off the top of my head, and I don't usually do
Windows.Forms stuff, so the exact syntax might be a bit wayward: but you
should get the idea.

HTH
Peter

"Boki" <bo******@ms21.hinet.netwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
Hi All,

There are two forms, when some click happen, it fires to set form2's
viable as enable.

The form2 is for user to input some text and then the data need to be
collected into form1's textbox.

I have created a function call as public, but I still can't use it in
form2.

Please advice. Thanks!

Best regards,
Boki.

Jul 10 '07 #5
On Jul 10, 10:52 am, Boki <bokit...@ms21.hinet.netwrote:

<snip>
Thanks, but I am not very understand here.

If we create another form, and then access to this form, why the
modified result also change the original form.... why not only the
copied form..
Have you perhaps got some static variables instead of instance
variables?

UI type work the same as "normal" types for the most part (except for
threading). Work out how you'd pass the information around in a non-UI
setting, then apply the same approach.

Jon

Jul 10 '07 #6

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

Similar topics

2
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...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
3
by: Christopher Koh | last post by:
how do you stop Access from saving any changed data in your tables and queries? like i just add or change data on the table/query tables,then click on X (exit)because i have no intention of saving...
9
by: MacDermott | last post by:
I have an Access MDB which instantiates a class in a custom DLL, manipulates it for a while, then sets it equal nothing. The MDB does other things,too, and generally behaves itself as desired....
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
0
by: Tony Hine | last post by:
Problem for Excel Developers One of the problems facing Excel developers moving into MS Access is actually the apparent similarity between MS Access tables and Excel spreadsheets. MS Access is...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Thank you for that. It was very...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
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
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,...
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.