PDA

View Full Version : [SOLVED] using Multipage within a Multipage form



Rob342
11-24-2013, 04:39 PM
HI
I Have a Multipage form with 12 pages on it, I have added to page 4 another Multipage (13 & 14) Multipage2
when a user enters data on Multipage2.Page13 and Updates the data, Page 13 is then hidden & should then show Page14 but it doesn't
Have tried the code below without success

Me.MutiPage2.Page14.Visible=True
Me.MultiPage2.Page13.visible=False

This works in a sense, it Shows Page 14 But with the fields From Page 13
How do 1 get it to show Page 14 with the relevant fields that only apply to Page 14
Tried setting the Values to1 & 0 doesn't work ?
Rob

Paul_Hossler
11-24-2013, 05:18 PM
This works in a sense, it Shows Page 14 But with the fields From Page 13
How do 1 get it to show Page 14 with the relevant fields that only apply to Page 14


When you dropped the data field controls onto MultiPage2, are you SURE you put them on your Page13?

Paul

mikerickson
11-24-2013, 05:46 PM
Try this. It should show Page14.

MultiPage1.Value = 13

Rob342
11-25-2013, 02:57 AM
Hi Paul & Mike
Thanks for the reply

Paul the text boxes are hard coded on the form
Mike tried this it error's out with 438 code

Have attached a sample form which works as it should but when I use this code in mine it doesn't work still shows the data on Prev Page 13

Cannot for life of me see why it does not work on my routine, got me baffled!
Rob

mikerickson
11-25-2013, 06:37 PM
Did you adjust the controls name in the code I wrote?

Also have you considered setting the .TabStyle property of the MultiPage to fmTabStyleNone and not fiddling with the visibility of the non-active pages. It looks like all the nagivation on MultiPage2 is done by controls and not by the user clicking on the tabs.

Paul_Hossler
11-25-2013, 09:25 PM
Have attached a sample form which works as it should but when I use this code in mine it doesn't work still shows the data on Prev Page 13

Cannot for life of me see why it does not work on my routine, got me baffled!

Since the logic seems to work in the WB you posted, I still think you should double^2 check the control placements in the real WB

I put a breakpoint on the Initialize event and used the Immediate Window to check the .Parent up the line.

Paul

Rob342
11-26-2013, 01:38 PM
Hi Mike & Paul

Have rechecked all codes & controls they are all correct to example posted
Been doing a bit of research and a lot of debugging within the code and found that the value of Multipage2.value always remaining at 0, the value doesn't change even when its in the programme code.

I found article on the msn forum where somebody else had the same problem, it seems like there is a bug in excel 2007 -2010, if trying to change the value programmatically.
Evidently it needs an Event to take place on the form ! to activate the change event ( which changes the value of the multipage2 from 0 to 1

So I changed the routine from the AfterUpdate on the textbox & transferred the code into a Command button (Which creates a click event), which in turn activated the change event(even though there was no code in the event)

The form now works as it should, but have you any idea's how to activate the change event, not using the command button ??
Why does MultiPage2 need this routine ?

Rob

mikerickson
11-26-2013, 07:22 PM
Have you considered my suggestion to keep all the pages visible, but eliminate the tabs.

From within the userform code module, you can trigger CommandButton1's Click event with
Call CommandButton1_Click.
If you want to call it from outside the uf code module, change the Private declaration to Public and use
UserForm1.CommandButton1_Click

Rob342
11-27-2013, 03:42 AM
Mike, Paul

Mike the command button call does not work, I have managed to replicate the problem on the attached.
If you input "Y" on Tb2 Page 8 nothing happens, which has the call code in the after Update.
Have all tabs visible.

If you press the command button on the Page 8 then it works ok, How do you explain that ?

Rob

Aflatoon
11-27-2013, 04:15 AM
Change the Button's TabStop property to False and then your AfterUpdate will work. Without that change, the focus must return to the button after your AfterUpdate code runs.

Rob342
11-27-2013, 12:50 PM
Thanks Aflatoon
That works, I have hidden a spare button on the form.
Rob