ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing Checkbox (https://www.excelbanter.com/excel-programming/341021-clearing-checkbox.html)

Jim May

Clearing Checkbox
 
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one or
the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

....Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub



Norman Jones

Clearing Checkbox
 
Hi Jim,

Change:

frmPOReq.ChkYes = ""


to

frmPOReq.ChkYes = False

Similarly, change:

frmPOReq.ChkNo = ""


to

frmPOReq.ChkNo = False

---
Regards,
Norman



"Jim May" wrote in message
news:QmlZe.121368$Ep.13713@lakeread02...
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one or
the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

...Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub





Bob Phillips[_6_]

Clearing Checkbox
 
Jim,

I don't know what is causing the problem, there must be some code we aren't
seeing. But ...

You don't need two checkboxes. If you think about it, a checkbox is just a
switch, it is either True (checked) or not True (unchecked). Yes and no are
also different switch statuses, so use one checkbox to indicate Yes
(checked) or No (unchecked)

frmPOReq.chkYesNo = (Target.Offset(0, 17).Value = "Yes")
frmPOReq.Show
End Sub


--
HTH

Bob Phillips

"Jim May" wrote in message
news:QmlZe.121368$Ep.13713@lakeread02...
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one or
the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

...Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub





Jim May

Clearing Checkbox
 
Norman,, You nailed-it; (that was the prob)
Tks,
Jim

"Norman Jones" wrote in message
...
Hi Jim,

Change:

frmPOReq.ChkYes = ""


to

frmPOReq.ChkYes = False

Similarly, change:

frmPOReq.ChkNo = ""


to

frmPOReq.ChkNo = False

---
Regards,
Norman



"Jim May" wrote in message
news:QmlZe.121368$Ep.13713@lakeread02...
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one
or the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

...Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub







Tom Ogilvy

Clearing Checkbox
 
First try

If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = False
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = False
End If
frmPOReq.Show
End Sub

--
Regards,
Tom Ogilvy


"Jim May" wrote in message
news:QmlZe.121368$Ep.13713@lakeread02...
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one or
the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

...Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub





Jim May

Clearing Checkbox
 
Right On !! - Tks Tom

"Tom Ogilvy" wrote in message
...
First try

If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = False
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = False
End If
frmPOReq.Show
End Sub

--
Regards,
Tom Ogilvy


"Jim May" wrote in message
news:QmlZe.121368$Ep.13713@lakeread02...
I'm running code that Fills a Dataform <<and all fields are working fine
except for the last two items which are checkboxes: the final step should
fill in one of the two separate checkboxes on my frmPOReq, but right now
the frmPOReq is showing in some cases BOTH checkboxes checked, with one
or
the other greyed out
on the form... Can someone tell me what I'm doing wrong here?

...Code before,,
If Target.Offset(0, 17).Value = "No" Then
frmPOReq.ChkNo = True
frmPOReq.ChkYes = ""
End If
If Target.Offset(0, 17).Value = "Yes" Then
frmPOReq.ChkYes = True
frmPOReq.ChkNo = ""
End If
frmPOReq.Show
End Sub








All times are GMT +1. The time now is 02:44 PM.

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