View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
giardina giardina is offline
external usenet poster
 
Posts: 3
Default Check Box in Forms

Dave,

Thanks. I spent the afternoon on that. I just put the -1*Me.Q().Value and it
worked.
Learning can be a real b.

"Dave Peterson" wrote:

In a worksheet, excel treats True as 1 in arithmetic operations.

But in VBA, excel treats True as -1 in arithmetic operations.

Option Explicit
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("WarrQAdata")

iRow = 6 'for testing

'copy the data to the worksheet
ws.Cells(iRow, 5).Value = -1 * Me.Q1.Value
ws.Cells(iRow, 6).Value = -1 * Me.Q2.Value
ws.Cells(iRow, 7).Value = -1 * Me.Q3.Value

'clear the data
Me.Q1.Value = False
Me.Q2.Value = False
Me.Q3.Value = False

End Sub

giardina wrote:

Thanks for the reply. This is what I have where Q() are the check boxes.
After copying to the weeksheet the form clears for the next entry. I'm not
sure how/where I would incorporate that sub.(?)

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("WarrQAdata")

'copy the data to the worksheet
ws.Cells(iRow, 5).Value = Me.Q1.Value
ws.Cells(iRow, 6).Value = Me.Q2.Value
ws.Cells(iRow, 7).Value = Me.Q3.Value

'clear the data
Me.Q1.Value = "True"
Me.Q2.Value = "True"
Me.Q3.Value = "True"

End Sub

"Howard31" wrote:

Hi giardina,

Try using another Variable, as follows:

Sub GetCheckBoxValue()
Dim NumerValue As Integer

If CheckBox1.Value = True Then
NumberValue = 1
Else
NumberValue = 0
End If

End Sub

Hope this helps,

--
A. Ch. Eirinberg


"giardina" wrote:

I'm sure my missing something, but I created a Form which adds records to a
worksheet. I have a series of check boxes in the form. When it records the
record it uses True or False. I'm trying to have it set as a numeric 1 or 0.
I've sreached around a bit but haven't found the property setting to
accomplish this. Needless to say my code writing skills are virtually
non-existent so.... any help would be appreciated. Thanks.


--

Dave Peterson