ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check Box in Forms (https://www.excelbanter.com/excel-programming/423057-check-box-forms.html)

giardina

Check Box in Forms
 
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.

Howard31

Check Box in Forms
 
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.


giardina

Check Box in Forms
 
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

Check Box in Forms
 
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

giardina

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


Dave Peterson

Check Box in Forms
 
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


All times are GMT +1. The time now is 06:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com