Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then with checkbox not working 3

Status
Not open for further replies.

Mezzzo

Technical User
May 30, 2003
56
US
Hi Group

I had made some changes to this code and added a checkbox as part of a if then statement. When I run the code for the checkbox if then, I can`t seem to get the results to populated in the grid. Am wondering what I`m going wrong.
The code in question has a note above it
PS what`s the difference, if any, between these statements.
optFrontInset.Value = True
Or
optFrontInset.Value = 1

'************** Applied FRONT **************
If OptAppliedFront.Value = True Then
If optFrontInset.Value = True Then
InsertRow irow, txtID, cbDrawerType.Text, "Applied Front" & " " & "(I)", _
QtyOne, ds(FrontInsetWidth, Mode), ds(FrontInsetLength, Mode), _
.matFront.material, ds(.matFront.thickness, Mode), _
ds(FrontInsetLength, Mode), txtNotes, 0
Else 'optFrtOverlay.Value = True Then
InsertRow irow, txtID, cbDrawerType.Text, "Applied Front" & " " & "(O)", _
QtyOne, ds(FrontOverlayWidth, Mode), ds(FrontOverlayLength, Mode), _
.matFront.material, ds(.matFront.thickness, Mode), _
ds(FrontOverlayLength, Mode), txtNotes, 0
End If
Note : This if then below does not seem to run.If checkNoFront.Value = 1 Then

If checkNoFront.Value = 1 Then
InsertRow irow, txtID, cbDrawerType.Text, " No Applied Front" & " " & "(O)", _
"0", "0", ds(FrontOverlayLength, Mode), _
.matFront.material, ds(.matFront.thickness, Mode), _
ds(FrontOverlayLength, Mode), txtNotes, 0
End If
irow = irow + 1

'************** Integral FRONT **************
ElseIf optIntegralFrt.Value = True Then
If optFrontInset.Value = True Then
InsertRow irow, txtID, cbDrawerType.Text, "Integral Front" & " " & "(I)", _
QtyOne, ds(FrontInsetWidth, Mode), ds(FrontInsetLength, Mode), _
.matFront.material, ds(.matFront.thickness, Mode), _
ds(FrontInsetLength, Mode), txtNotes, 0
Else ' optFrtOverlay.Value = True Then
InsertRow irow, txtID, cbDrawerType.Text, "Integral Front" & " " & "(O)", _
QtyOne, ds(FrontOverlayWidth, Mode), ds(FrontOverlayLength, Mode), _
.matFront.material, ds(.matFront.thickness, Mode), _
ds(FrontOverlayLength, Mode), txtNotes, 0
End If
irow = irow + 1
End If
End With
End Sub
 
I found by using option buttons, that using the value as 1 or 0 works for me.

Example:
----------------------------------------------------------
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0
If Option1(0).Value = 0 Then
Option1(0).Value = 1
'//do more code here.
Else
Option1(0).Value = 0
'//do some other code.
End If
'
Case 1
'
Case 2
'//and so on.
End Select
End Sub
------------------------------------------------------------

So, your question about what's the difference? I don't know, but all I know is that the ONE ( 1 ) & ZERO ( 0 ) always been used in my case and they work wonderfully.

Hope I was of some help,

Andrew.
 
Checkboxes actually can contain 3 values (checked, unchecked, and grayed-out). Try using the constants included with VB for this:
Code:
if chkCheckbox1.Value = vbChecked Then
   ' Do checkbox 1 stuff
End If

If chkCheckBox2.Value = vbUnchecked Then
   ' Do other stuff when Checkbox2 isn't checked
End If
Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
You have nested IFs checking different option buttons for true, if these are in the same container only one can be true.

The checkbox check is only executed if OptAppliedFront is true.

You should use vbChecked/vbUnchecked but its not relevant to the problem.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top