PDA

View Full Version : Solved: User Form Problem



mpewsey
07-25-2006, 03:53 AM
Hopefully I can explain my problem clearly!

When a user clicks on a button on user form A then user form A is hidden & user form B is shown which, when initializing, takes some data from user form A.

I've now got a user form C which has a button on it to show user form B. However, I get a run time error when it initializes as it's looking for data from user form A rather than user form C.

Is there a way I can check whether user form A or User form C is the hidden user form that called user form B (presumably using an IF somewhere along the line)?

There will never be the possibility of both A & C being hidden at the same time.

I've considered copying the data into a worksheet or duplicating user form B but neither of these solutions seem very 'tidy'.

Martin

asingh
07-25-2006, 04:33 AM
Hi...

are you hiding form A when C has the focus..or are you killing the instance..of A....just use hide...A..then C should work fine...dont kill the instance...!

Bob Phillips
07-25-2006, 05:00 AM
No, userform B should be told which form opened it, via a form property.

asingh
07-26-2006, 04:45 AM
Let me get the form "flow" correct here. Form A loads. A button on A is clicked and form B is shown, which "pulls" data from A, and A is than hidden. Now only user form B is visible to the user.

From where does user form C come...? How is this being shown to the user. And if it is being shown somehow...then both A and C have buttons to invoke B. Can there B an instance when both A and C are visible to the user..?

CEQ2000
07-27-2006, 11:58 AM
Maybe instead of having form B getting the required info from form A or C, why not just have form A and form C push their information to form B when they call form B?

mpewsey
07-27-2006, 03:20 PM
Apologies for not getting back sooner - my PSU died on me:(

OK to try to make it a bit clearer.: pray2:

Forms A & C are called from separate parts of my code - A is almost an input sheet whereas C is almost a report (sorry - I can't think of a better way to describe it).

Both of them have a button which calls up form B to give them more info.

The suggestion from CEQ2000 about 'pushing' the data rather than 'pulling' it seems to be the sort of thing I need to happen but is something I haven't got a clue how to do.

I would post a copy of my workbook but there is some highly confidential information in it the removal of which would render my workbook inoperable - leaving it in would render me out of a job and possibly worse.

I've always just opened a user form by using 'show'. I'm guessing now (so no laughing ), is it possible to 'load' (ie: frmB.load) a user form, push the data across(ie: frmB.xxx=123) & then 'show' it (obviously cutting out the bit in the Initialize code that was pulling the data from form A)?

Martin

CEQ2000
07-28-2006, 05:30 AM
You have the right idea. Basically try

Load formB
formB.TextBox1 = "information from form A or Form C"
formB.TextBox2 = "More information from form A or Form C"
formB.Show

This should work for what you are trying to do.

mpewsey
07-28-2006, 09:55 AM
Works a treat - many thanks!

Martin