PDA

View Full Version : Solved: copy data from one userform to another



Pete
01-08-2009, 05:51 AM
hi experts

Need a macro that well copy data from Userform frmform1 to Userform frmform2 if the user know that the two details are the same.

i.e. if the Site A Address details in form frmform1 are the same as Landlord Address then the user can click the macro button in form frmform2 "Copy Address Details" and these would be populated into the Landlord address field.

i have not yet set up a button to open up the user form from the fornt page of the worksheet....as yet.

georgiboy
01-08-2009, 06:39 AM
If userform2 is opened from a button in userform1 for example using the "Next" button leaving both userforms open at the same time then you could use something like...

UserForm2.txtPostalCodeA.Value = UserForm1.txtPostalCode.Value

for each textbox you want to copy over.

Hope this helps

Pete
01-08-2009, 07:23 AM
Hi

Both form are not open at the same time on next click the first form is closed.....

Pete
01-08-2009, 07:47 AM
tried and tested the above getting a compile error: method or data member not found

lucas
01-08-2009, 08:30 AM
Pete, are the Site A Address details in form frmform1 added to the worksheet before/when frmform1 is closed? If so you can retrieve the info from the range of the sheet.

Pete
01-08-2009, 09:25 AM
Hi Lucus

What happens is i add the siteA form 1 details in then navigate to for 2 using the next button. if they are the same then i wish to click a macro to copy field data accross as opposed to re-typing it all out again....

lucas
01-08-2009, 09:45 AM
Well, your userforms and explainations are confusing so just to pin you down.....

On userform1(please be specific) you want the text in textbox txtBuildingName to be transferred to userform2 into textbox txtBuildingNameA

when you hit the Next button or when you hit the button on userform 2 that says "Copy address details" Which one do you want to happen.

Is that correct so far?

Pete
01-08-2009, 09:48 AM
Hi Lucus

On userform1(please be specific) you want the text in textbox txtBuildingName to be transferred to userform2 into textbox txtBuildingNameA - yes

when you hit the Next button or when you hit the button on userform 2 that says "Copy address details" Which one do you want to happen. - when i hit the copy address details button and only then and not on clicking the next button.




Is that correct so far?

lucas
01-08-2009, 10:09 AM
On userform 1 when you hit the finish & save button is the data in textbox txtBuildingName supposed to be added to the sheet1 range M-AA row 25?

Pete
01-08-2009, 10:18 AM
hi Lucus

On userform 1 when you hit the finish & save button is the data in textbox txtBuildingName supposed to be added to the sheet1 range M-AA row 25? - NO

This data is going somewhere else.......

lucas
01-08-2009, 10:20 AM
I Need to know where......is it a secret?

georgiboy
01-08-2009, 10:31 AM
LOL..... Secret?, Sorry had to laugh.

You could make it very simple if you could keep everything in one workbook then maybe export it after you have completed the tasks with the forms. See example.

lucas
01-08-2009, 10:45 AM
Hi georgiboy, your method leaves both userforms open which is an option. Another is to use a global variable but I was just looking for a simple solution as this project seems to be in the very earliest stages, ie if the data is placed in the worksheet....just retreive it from there.

georgiboy
01-08-2009, 11:03 AM
Lucas,

I see where you are coming from with taking the data from where it is put and keeping it simple. This is why i have suggested keeping all in one workbook then exporting at a later point in the code (when the second userform is closed), it may only take adding one more worksheet to hold the data until it is time to move it to another workbook. I suppose there is a few ways to achieve this and i am interested to see wich route is taken. As your knowledge of VBA is far greater than mine i will leave it to you.

I like to see multiple inputs from people on this forum as it will normally will end up with the most suited solution, i have learned all i know from this forum and i will continue to poke my nose in all the time i am allowed to do so. I am on my third glass of wine now so i should probably go. :stars:

lucas
01-08-2009, 11:21 AM
georgiboy,
Please continue to contribute when you feel like you can add to the conversation......the more the merrier and often many ideas come from such conflaberations......

I'm jelous of the wine drinking.....it's still early here.

I was just continuing the conversation so don't think it was criticizm please.

georgiboy
01-08-2009, 12:48 PM
I was just continuing the conversation so don't think it was criticizm please.

I dont, trust me all is well. :cloud9:

Pete
01-09-2009, 01:38 AM
hi georgiboy (http://www.vbaexpress.com/forum/member.php?u=15252) vbmenu_register("postmenu_172449", true);

the example workbook works prefect thanks for the excellent feedback....