Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You didn't really include () in your expression:
-1*Me.Q().Value did you???? giardina wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Increase size of a Forms Check Box (click on to enter check mark) | Excel Discussion (Misc queries) | |||
Hiding a check box from forms | Excel Discussion (Misc queries) | |||
Forms/ Check Box | Excel Discussion (Misc queries) | |||
Check box in Forms Toolbar | Excel Discussion (Misc queries) | |||
check off, look up forms - VERY confused | Excel Discussion (Misc queries) |