Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Multipage Query

Just alter this to address all the textboxes you want included:

TextBox8.Text = CLng("0" & TextBox2.Text) + _
CLng("0" & TextBox3.Text) + _
CLng("0" & TextBox4.Text) + _
CLng("0" & TextBox5.Text) + _
CLng("0" & TextBox6.Text) + _
CLng("0" & TextBox7.Text)

Perhaps calculate a subtotal for each page and then add the subtotals
together to simplify.

or you could do this:

Private Sub CommandButton1_Click()
Dim pg As Page

For Each pg In Me.MultiPage1.Pages
If pg.Index < 0 Then
For Each ctrl In pg.Controls
If TypeOf ctrl Is MSforms.TextBox Then
Sum = Sum + CLng("0" & ctrl.Value)
End If
Next
End If
Next
Me.TextBox4.Value = Sum
End Sub


In my test setup, Textbox4 was the textbox on the first page of the
multipage to hold the result.

--
Regards,
Tom Ogilvy




--
Regards,
Tom Ogilvy

"MDL2004" wrote in message
...
Hi

I'm trying to use a multipage to help with input data quickly into a main
spreadsheet. Design wise everything is fine, it's just i'm trying to
calculate the total of each multipage(8 in all) to give a subtotal as the
user tabs through each page.
I've used some code that i picked up on from the discussion group but it
only adds up page 1 and I need the same code to calculate pages 2 onwards.

I've attached the code in case anyone can put me straight as I am unsure
what I'm doing wrong!!

Private Sub textbox2_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox3_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub textbox4_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub textbox5_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox6_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox7_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub Calctotal()
TextBox8.Text = CLng("0" & TextBox2.Text) + _
CLng("0" & TextBox3.Text) + _
CLng("0" & TextBox4.Text) + _
CLng("0" & TextBox5.Text) + _
CLng("0" & TextBox6.Text) + _
CLng("0" & TextBox7.Text)

End Sub

Private Sub userform_click()




End Sub

Look forward any comments



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Multipage Query

Cheers Tom

Tried what you suggested and it has done the trick, just what i was trying
to do!!
Thanks again!!

"Tom Ogilvy" wrote:

Just alter this to address all the textboxes you want included:

TextBox8.Text = CLng("0" & TextBox2.Text) + _
CLng("0" & TextBox3.Text) + _
CLng("0" & TextBox4.Text) + _
CLng("0" & TextBox5.Text) + _
CLng("0" & TextBox6.Text) + _
CLng("0" & TextBox7.Text)

Perhaps calculate a subtotal for each page and then add the subtotals
together to simplify.

or you could do this:

Private Sub CommandButton1_Click()
Dim pg As Page

For Each pg In Me.MultiPage1.Pages
If pg.Index < 0 Then
For Each ctrl In pg.Controls
If TypeOf ctrl Is MSforms.TextBox Then
Sum = Sum + CLng("0" & ctrl.Value)
End If
Next
End If
Next
Me.TextBox4.Value = Sum
End Sub


In my test setup, Textbox4 was the textbox on the first page of the
multipage to hold the result.

--
Regards,
Tom Ogilvy




--
Regards,
Tom Ogilvy

"MDL2004" wrote in message
...
Hi

I'm trying to use a multipage to help with input data quickly into a main
spreadsheet. Design wise everything is fine, it's just i'm trying to
calculate the total of each multipage(8 in all) to give a subtotal as the
user tabs through each page.
I've used some code that i picked up on from the discussion group but it
only adds up page 1 and I need the same code to calculate pages 2 onwards.

I've attached the code in case anyone can put me straight as I am unsure
what I'm doing wrong!!

Private Sub textbox2_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox3_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub textbox4_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub textbox5_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox6_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub
Private Sub textbox7_keypress(ByVal keyascii As _
MSforms.ReturnInteger)
If keyascii < Asc("0") Or keyascii Asc("9") Then
Interaction.Beep
keyascii = 0
End If

End Sub

Private Sub Calctotal()
TextBox8.Text = CLng("0" & TextBox2.Text) + _
CLng("0" & TextBox3.Text) + _
CLng("0" & TextBox4.Text) + _
CLng("0" & TextBox5.Text) + _
CLng("0" & TextBox6.Text) + _
CLng("0" & TextBox7.Text)

End Sub

Private Sub userform_click()




End Sub

Look forward any comments




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
MultiPage tab? capt Excel Discussion (Misc queries) 2 January 28th 08 08:01 PM
MultiPage OM Excel Discussion (Misc queries) 2 April 7th 06 01:31 PM
How do I use multipage Lawrence M Watt Excel Discussion (Misc queries) 1 October 24th 05 02:55 PM
vba - using multipage ajliaks[_23_] Excel Programming 3 August 9th 04 01:29 PM
Multipage Aksel Børve Excel Programming 1 March 1st 04 08:52 AM


All times are GMT +1. The time now is 03:09 PM.

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

About Us

"It's about Microsoft Excel"