Check box blues

S

simon.q.rice

I've been creating a questionnaire for my local school (yes I know that
there are web-based databases available....) with an Excel spreadsheet
running in the background to collect the data. Each slide has a series
of option buttons from the control toolbox and clicking them fires an
event in the spreadsheet which increases a cell value by 1 and then
advances to the next slide. Run in kiosk mode it works well.

However one of of the slides has check boxes instead of option buttons.
Using the Checkbox_Click event it fires the accompanying procedure in
the spreadsheet but here is my problem. I have a commandbutton on this
slide to advance to the next slide and set all the checkbox values to
false. However the commandbutton event fires the associated Excel
script a second time as it sets the checkbox values to zero and my data
increases in multiples of 2 rather than 1 for each visit.

Does any one have any suggestions how I might prevent this second
firing of the associated events when the checkbox values are returned
to zero.

Example code for the check box event:

Private Sub CheckBox1_Click()
Dim xlApp As Excel.Application
CommandButton1.Enabled = True
Set xlApp = GetObject(, "Excel.Application")
xlApp.Range("H42").Select 'change
xlApp.ActiveCell.FormulaR1C1 = xlApp.ActiveCell.Value + 1
End Sub

Code for my ComandButton_Click event

Private Sub CommandButton1_Click()
ActivePresentation.SlideShowWindow.View.GotoSlide 24 'change
CommandButton1.Enabled = False

CheckBox1.Value = 0
CheckBox2.Value = 0
CheckBox3.Value = 0
CheckBox4.Value = 0
CheckBox5.Value = 0
CheckBox6.Value = 0
CheckBox7.Value = 0

End Sub

Many thanks in anticipation

Simon
 
B

Bill Dilworth

Why not eliminate the checkbox event writing and only write to the excel
file when the next slide button is pressed? Otherwise, a user could sit on
the slide and just toggle the checkbox a hundred times to befuddle your
counter.
---------------
Private Sub CommandButton1_Click()

'Add counter code
Dim xlApp As Excel.Application
Set xlApp = GetObject(, "Excel.Application")
xlApp.Range("H42").Select 'change
xlApp.ActiveCell.FormulaR1C1 = xlApp.ActiveCell.Value + 1

'Original Next slide code
ActivePresentation.SlideShowWindow.View.GotoSlide 24 'change
CommandButton1.Enabled = False

CheckBox1.Value = 0
CheckBox2.Value = 0
CheckBox3.Value = 0
CheckBox4.Value = 0
CheckBox5.Value = 0
CheckBox6.Value = 0
CheckBox7.Value = 0

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top