Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2009, 07:02 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sum Total Checkboxes on a Multipage Form

Hi All,

I have a function which is intended to collate the sum total of checkboxes checked on a mulitpage form. Each checkbox has a numerical value and these values are referenced on an underlying excel spreadsheet (worksheet 3). I have been unsuccessful in getting the checkboxes to sum total what has been selected. However, I have gotten this same function to work if I embed the checkboxes onto the excel spreadsheet itself, but i need this to work on in forms. Any ideas on where the link is broken so to speak?

Private Sub CommandButton1_Click()
'
' Sum checkboxes
'
Dim rngCheckTable As Range
Dim Chk As Object
Dim dblTotal As Double
Dim dblValue As Double

On Error Resume Next

Set rngCheckTable = Excel.Worksheets(3).Range("A1:B11")
For Each Chk In frmViewResults.MultiPage1.Pages(0)
If TypeName(Chk.Object) = "CheckBox" Then
dblValue = 0
If Chk.Object.Value = True Then
dblValue = Application.WorksheetFunction.VLookup(Chk.Name, rngCheckTable, 2, 0)
End If
dblTotal = dblTotal + dblValue
End If
Next

txtbxQuantityScore.Text = dblTotal

MsgBox "Total is " & dblTotal

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the sum of selected checkboxes? Colleen Javascript How-To 4 March 7th, 2006 01:34 PM
Sum on a form Problem Corey Access 1 November 9th, 2005 05:43 PM
Form element "memory" - for checkboxes SoC VBScript 1 September 1st, 2004 04:35 AM
How to create a total on a form (using.... Mita Access 3 October 8th, 2003 12:48 AM
Dynamic form checkboxes Claralu Classic ASP Databases 2 August 5th, 2003 12:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.