Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default MultiPage exit/change event

I use a MultiPage control to gather data and have it placed on my
worksheets. I have code which causes the data to be placed on the worksheet
when you exit one (of 10) TextBox for another, my problem is if the user
clicks on the next page of the MultiPage control, Excel does not recognize
it as an exit event from a TextBox. So the value is not placed on the
worksheet.

I used this approach (as opposed to just placing the data on the worksheet
upon closing the UserForm,which is easy) because I have a TextBox on the
UserForm which must be updated as numbers are entered. Now someone suggested
that I use the code below.

As you can see I want to apply this code to MultiPage2. I tried many
variants of the suggested code, but was not able to get more than the first
page to update when I clicked to another page. MultiPage2 control has 6
pages (January, February, March, April, May, June). This is where I am now,
but again it only works when I click from January to any of the other pages.

Proposed code:

Private Sub YourMultiPage_Change()
If MultiPage.Value = 0 Then 'First Page
'TextBox handling here
End If
End Sub



Adapted Code:

Private Sub MultiPage2_Change()

If MultiPage2.Value = 0 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 1 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 2 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 3 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 4 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 5 Then
PopulateWorksheets.PopulateWorksheets

End If

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default MultiPage exit/change event

Patrick
if you want it update when you change any to any page.you dont need:
If MultiPage.Value = 0 Then

eg:
Private Sub YourMultiPage_Change()
'TextBox handling here


End Sub

for MultiPage2
you don't need more than...if it applies to all pages

Private Sub MultiPage2_Change()
PopulateWorksheets.PopulateWorksheets
End Sub

let me know if I misunderstood...HTH

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MultiPage exit/change event

I set up you situation and modified you code slightly

Private Sub MultiPage2_Change()

If MultiPage2.Value = 0 Then
MsgBox "Page is 0"

ElseIf MultiPage2.Value = 1 Then
MsgBox "Page is 1"

ElseIf MultiPage2.Value = 2 Then
MsgBox "Page is 2"

ElseIf MultiPage2.Value = 3 Then
MsgBox "Page is 3"

ElseIf MultiPage2.Value = 4 Then
MsgBox "Page is 4"

ElseIf MultiPage2.Value = 5 Then
MsgBox "Page is 5"

End If

End Sub

worked as expected for me.

If the code you show is your actual code, then how does
PopulateWorksheets.PopulateWorksheets know what to do. There is no use
using your if/elseif construct if you issue the same exact command in each
one. If the PopulateWorksheets code is smart enough to check which page is
active, then you don't need the If statements.

Also, you are getting the page that was activated, not the page that was
departed.

Another problem is that if the User selects something else (the other
multipage or somewhere else on the userform), you don't trigger this event.

I think you will need to sense when the user is moving away from the current
page.

Private Sub MultiPage2_MouseMove(ByVal Index As Long, ByVal Button As
Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Application.StatusBar = MultiPage2.Value & " x: " & X & " y: " & Y
End Sub

will show you that the mousemove event fires continuously as you move the
mouse over the page. (the display is in the statusbar - make sure it is
visible). In that event, you can compare the x and y locations to the
boundaries toward the edges of the page. If the user goes outside that
boundary, then you can perform your "exit" actions. Use a public variable
with the enter events of the textboxes to hold information on which textbox
was entered. Then reset it in the exit event. If the user approaches the
boundary and this variable is set, then clear the variable and perform the
"exit" action.

This concept would replace your current concept.

--
Regards,
Tom Ogilvy



"Patrick Simonds" wrote in message
...
I use a MultiPage control to gather data and have it placed on my
worksheets. I have code which causes the data to be placed on the worksheet
when you exit one (of 10) TextBox for another, my problem is if the user
clicks on the next page of the MultiPage control, Excel does not recognize
it as an exit event from a TextBox. So the value is not placed on the
worksheet.

I used this approach (as opposed to just placing the data on the worksheet
upon closing the UserForm,which is easy) because I have a TextBox on the
UserForm which must be updated as numbers are entered. Now someone
suggested that I use the code below.

As you can see I want to apply this code to MultiPage2. I tried many
variants of the suggested code, but was not able to get more than the
first page to update when I clicked to another page. MultiPage2 control
has 6 pages (January, February, March, April, May, June). This is where I
am now, but again it only works when I click from January to any of the
other pages.

Proposed code:

Private Sub YourMultiPage_Change()
If MultiPage.Value = 0 Then 'First Page
'TextBox handling here
End If
End Sub



Adapted Code:

Private Sub MultiPage2_Change()

If MultiPage2.Value = 0 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 1 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 2 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 3 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 4 Then
PopulateWorksheets.PopulateWorksheets

ElseIf MultiPage2.Value = 5 Then
PopulateWorksheets.PopulateWorksheets

End If

End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
exit event John Pierce Excel Programming 3 February 2nd 06 01:00 AM
Stoppoing ComboBox Change Event from firing when Multipage changes GH[_2_] Excel Programming 0 December 22nd 04 03:56 PM
Deactivating Multipage Change Event [email protected] Excel Programming 0 September 9th 04 03:13 AM
Deactivating Multipage Change Event [email protected] Excel Programming 2 September 9th 04 02:49 AM
Exit Event Michael J. Malinsky Excel Programming 1 February 27th 04 06:40 PM


All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"