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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word VBA - Multipage userform

Status
Not open for further replies.

lbb4ever

Programmer
Aug 31, 2001
8
US
Hi,
I have created a multipage userform for a Word [2003] document. One of the pages has numerous checkboxes. For each checkbox, there is a corresponding page/tab that will become visible when set to True.

My issue is trying to create Previous/Next commands so the user can easily move from one page/tab to the next. I can get Previous/Next to work just fine if all of the pages are visible. The problem is when there are invisible pages (the user did Not check one, or more, of the checkboxes).

Here's the code I have for the spin buttons:

Private Sub spinButton_SpinDown()
myIndex = Me.MultiPage1.SelectedItem.Index
Me.MultiPage1.Value = myIndex - 1
End Sub

Private Sub spinButton_SpinUp()
myIndex = Me.MultiPage1.SelectedItem.Index
Me.MultiPage1.Value = myIndex + 1
End Sub

So, the code reads what the current page's Index is and increments (or decreases) it by 1. That's great if the page with Index 5 is visible. However, if the Index goes from 4 right to 6, the button doesn't work.

How can I loop through the multipage control and collect an array of the pages indexes? And how do I get the buttons move from page one to the other regardless of invisibility?

Thank you in advance! I am stumped!
 
That's great if the page with Index 5 is visible. However, if the Index goes from 4 right to 6, the button doesn't work."

"And how do I get the buttons move from page one to the other regardless of invisibility?"


I am not following what you mean.

Define what WOULD work actually means. If 5 is invisible...what do you want to happen? It stay visible? It remain invisible? I do not understand what your goal is. I do not understand what "buttons move from page one to the other" means.

Gerry
 
Thanks for the reply, Gerry.

The buttons are Previous/Next buttons. They remain static on the form - they are not on the multipage. I need those buttons for the user to navigate from one page to the next in succession. Like the scroll buttons that automatically show up if your form has too many pages to fit in the screen.

The first part of my post says "For each checkbox, there is a corresponding page/tab that will become visible when set to True." If checkbox 1 is true, then a page will become visible for the user. If checkbox 3 is true, then that page will become visible for the user. However, if the user does NOT mark a box, the page is still there, but it is invisible.

The navigation buttons should move back and forth through the pages. And they would work correctly if all the pages were visible.

Is that helping? Attached is a screenshot of the form, more or less. By default, all tabs after "Other" are invisible unless their checkbox is checked. I want the user to use the buttons I provide to move from one page/tab to the next without them having to click on the tabs.
 
 http://main.allmyminds.us/imgs/vbaform.png




Why not test the visible property? If not then next/prev.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
You're BEAUTIFUL!

Here's what I got:

Private Sub spinButton_SpinUp()
myIndex = Me.MultiPage1.SelectedItem.Index

imVisible = False
Do Until imVisible = True
Me.MultiPage1.Value = myIndex + 1
If Me.MultiPage1.SelectedItem.Visible = True Then
imVisible = True
End If
Loop

It's Working! Woo Hoo!

Thanks Gerry :)
 
Nope. Simply put, you did not answer the question. I will ask again.

What do you want to happen? If a given page is invisible (its checkbox is not checked), what do you want your Next/Previous to do?

Make it visible?
Ignore it?

From your first post..."And how do I get the buttons move from page one to the other regardless of invisibility?"

THAT implies - "regardless of invisibility" - that IF a page is invisible, clicking the button will make it visible.

It is simple: yes...or no

What do want to happen?

To hopefully assist though, maybe this can help.
Code:
Private Sub SpinButton1_SpinUp()
Dim j As Long

[COLOR=red]' this is the CURRENT page index number[/color red]
j = Me.MultiPage1.SelectedItem.Index
[COLOR=red]' this is the NEXT page index number[/color red]
j = j + 1
[COLOR=red]' check to see if it is visible[/color red]
If Me.MultiPage1.Pages(j).Visible = False Then
   MsgBox "Invisible."
[COLOR=red]    ' and do NOTHING else?????[/color red]
Else
[COLOR=red]   ' it IS visible[/color red]
   MsgBox "Visible"
   ' make it the new CURRENT page
   Me.MultiPage1.Value = j
End If
End Sub
This does not stop the question of: what do you want to happen?

For example, suppose you are at the second to last page, and the LAST page is invisible. What do you want to happen? Nothing? Cycle through and set it at the FIRST page (if it is visible)?

Gerry
 
Haha. I didn't realize someone else answered. Sorry! Thank you Skip. Thank you Gerry.

Oh, the answer was "ignore it".
 
You have crossed posted this. There is nothing inherently wrong with cross-posting, but please LET US KNOW when you do.



Gerry
 
Where did I cross post it? I did post it another site, but not this one.
 



Yes, in ANY other place!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry. It's a big 'net out there. You guys are great, but there are other forums I use as resources. I understand not posting in another forum on this site, but to not post ANYWHERE else on the internet...?
 
Not anywhere...similar forums. Heck, go ahead and post in one a cooking forum, but many of us post answers in multiple forums. It is a little annoying to work on an answer in one forum, and then find out the answer has been already given in a different one.

So. It is polite to mention you have also posted it elsewhere. That gives us an option. We can take a peek at the other forum, and hey...it has already been answered





so.............


I do not need to answer it HERE.

Get it? Again, no one is saying do not cross post. We are saying let us know, so we do not waste our time.

Like your cross-post at VBAExpress. I am NOT going to answer it there, as I have already answered here. Now suppose someone else is looking at the VBAExpress thread, and they do NOT know it has been answered here at Tek-Tips. Now suppose they work out an answer and post it.

A) it is a wasted/duplicate effort
B) it is possible that you would not even look at the VBAExpress thread...as you HAVE the answer from here.

In which case;

C) the person who posted the answer at VBAExpress may be miffed because you do not respond, OR

D) become miffed that they put a bunch of work into an answer that was already given.

It is simple politeness to let us know, and is appreciated.

Gerry
 
I see. I didn't realize that. I will remember next time.

Thanks Gerry
 
Not a problem. I realize it seems, oh, I don't know...petty? But it is not actually. We are not paid, and some answers (not yours especially) take some effort. I know I have personally spent over an hour working out a response, only to find the person had crossed posted and received an answer (exactly the same as mine) on a different forum.

If I had known.......

I am glad you took the comment/request well (some do not!).

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top