Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automation of copying Data from one form to another in VB .net

Status
Not open for further replies.

Maikiro

Technical User
Feb 14, 2017
3
0
0
GB
Good evening all,
First off I have not programmed in over 20 years so this is a steep learning curve for me.

I have multiple forms with the first nine fields are identical. I am wanting to copy those Nine fields to each form as it is called.

I call these forms by a combobox using an if statement and I am wanting to make my code neat and short and not long winded.
As you can expect having 10 - 11 options within a ComboBox to call that many forms and then copy the data over.

So far I have searched google and not found anything helpful as I think I am looking in the wrong way.
Please don't treat me like an idiot as other forms have.. ta

If you need a copy of my code so far I can supply.

 
Ok worked out a different way.
I create a Public Sub and put in the nine fields I want to copy to all forms and then call when needed....

Now why did I not think of that in the first place. :(
 
So you are going to have 10 or 11 Forms, 9 fields will be the same on all Forms. I assume user can see only one form at the time (is that correct?)

If so, I would create just 1 Form with the 9 fields, and create 10 or 11 frames / group boxes / tab control / whatever on this one Form and display one at the time depending on what user wants to see.

"I call these forms [frames / group boxes] by a combobox using an if [select case] statement and I am wanting to make my code neat and short and not long winded."
That will do it, in my opinion. :)

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Andrzejek - That is such an awesome idea, I did not think of that... Thank you very much..
 
I've used the option suggested by Andrzejek many times in the past. However I normally use that for just a few common controls. When a lot of common controls are involved I tend to create a new form containing just those controls and subsequently inherit from it and add any additional controls to the inherited form.
 
Sorry, I omitted mentioning that when there is data that needs to be copied in the way you require, I tend to create a class with properties to hold the data and therefore quickly and easily load it into each relevant control. The controls can be populated on each individual form's load event.
 
I am glad you like my idea :)
Others - like softhemc - do this more 'sophisticated' way, but I am just a simple guy...

And as far as your other comment:
"Please don't treat me like an idiot as other forms have.. ta"
Here on TT nobody does it to others (unless you really, really ask for it )

Welcome to Tek-Tips [wavey3]

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Welcome to Tek-Tips.

Please don't treat me like an idiot as other forms have.. ta

That is something we don't want here@Tek-Tips. I can remember when I was ignorant of the stuff I know now. That stuff came by way of lots of people more knowledgeable that I, and for that I am grateful.

I know that there are also lots of contributing members who feel the same way. We all work to keep it that way and make it better.

So we hope you'll stick around, learn lots of good stuff and contribute as you are able and willing.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I didn't notice the "Please don't treat me like an idiot as other forms have.. ta" line initially.

I agree with both Andrzejek and SkipVought and would also draw you attention to the two links at the bottom right of each post. The first is self explanatory, but the second is there to enable you report anything "unpleasant".

By the way, if you post your sample code, we could see what might be possible with regard to making it a bit neater.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top