Transferring data between two userforms problem .

Pacman52

Active Member
Joined
Jan 29, 2009
Messages
319
Office Version
  1. 365
Platform
  1. Windows
Hi all I was just doing some final testing on a workbook I've been working on and stumbled across a problem that I have no idea on. My VB knowledge is very basic and I don't know where to look in the code to resolve the issue which is:

I have a worksheet called 'Home', on the sheet I have some buttons to open a Userform containing a button called 'Add New' which unloads this Userform and opens another one called 'New' - all works ok so far.

I fill in the required boxes on the 'New' form and once completed I then have a message box to ask if I want to open another form 'Details' if I select yes the 'Details' from opens and the 'New' form is hidden, if I select No the data is written to the relevent worksheet .

The problem I'm having is I need the data that is entered on the 'New' form transferred over to the 'Details' form which it does but ONLY if I open the form from within the VBA window, If I start the process by clicking the button on the 'Home' worksheet the data doesn't get transferred over to the 'Details' form.

Hopefully what I've written makes sense and someone could point me in the right direction on where to look in the code to fix this. I've tried to keep it a simple post by not posting any of my code but more than happy to if it would help in finding a solution.

Many thanks Paul
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Seeing your code might have helped. It should be as simple as userform1.TextBox1 = userform.TextBox1 (note the 2 userform names are not the same).
Not sure if either or both cannot be modal, but I suspect as much. If the data you need to input is not a lot, why not just show/hide a set of controls and eliminate 1 or both of the subsequent forms?
 
Upvote 0
And if what Micron suggests doesn't work, you could take a slightly longer winded approach and store the data on a hidden sheet when the first from closes, and recall it to the next form when it opens. That is if you must have the two separate forms.
 
Upvote 0
Perhaps earlier forms are closed, but after reviewing again, I don't see that being mentioned. New is hidden, not closed, when Details opens? As I read it, data transfer is between New and Details, not between "userform" and New.
 
Upvote 0
Seeing your code might have helped. It should be as simple as userform1.TextBox1 = userform.TextBox1 (note the 2 userform names are not the same).
Not sure if either or both cannot be modal, but I suspect as much. If the data you need to input is not a lot, why not just show/hide a set of controls and eliminate 1 or both of the subsequent forms?
Thank you Micron - this reply was enough to help me find where the issue was - I checked doubled the properties of each form and one of them had the Modal set to True once I changed that to false its all working now - thanks again

Paul
 
Upvote 0
And if what Micron suggests doesn't work, you could take a slightly longer winded approach and store the data on a hidden sheet when the first from closes, and recall it to the next form when it opens. That is if you must have the two separate forms.
Thank you so much for reply and the tip. As per my post a moment ago the issue is resolved but I will certainly remember the 'hidden sheet' option for the future .

Paul
 
Upvote 0
one of them had the Modal set to True once I changed that to false its all working
I thought that might be the issue because if userforms are like M$ Access forms in that respect, then when calling code opens a modal form, the calling code halts until the called form is closed. So it might work if the called form pulled in the values but not if you try to "push" them into the modal form from the calling form code. Glad I could help. If you have a solution, perhaps mark your thread as solved. Thanks.
 
Upvote 0
Solution
I thought that might be the issue because if userforms are like M$ Access forms in that respect, then when calling code opens a modal form, the calling code halts until the called form is closed. So it might work if the called form pulled in the values but not if you try to "push" them into the modal form from the calling form code. Glad I could help. If you have a solution, perhaps mark your thread as solved. Thanks.
Sorry forgot to mark as solved but done now Thanks for the prompt.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top