By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Checkbox code problem

P: n/a
I need anyone that have done this before to help me. I'm creating a
form in Access, in the form has two two checkbox, checkbox A is paid,
checkbox B is partial_paid. I want the set the checkbox so that if the
user click on checkbox A which is Paid, then checkbox B which is
partial_paid should be disable, visa versa, then if checkbox A which
is Paid is uncheck then checkbox B becomes visible. This is the code
I have so far but when I uncheck checkbox A, checkbox B does not
appear. Please help me.

Private Sub chkPaid_Click()
If chkPaid.Enabled = True Then
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = False

Else
chkPaid.Enabled = False
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = True
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Why not use an option group instead of individual check boxes. That way only
one or the other can be selected at a time!

If you want to use your method though, you don't want to check for enabled
because even when it's not selected it's still enabled just not checked.
What you want to check for is true(-1) or False(0) Like so:

Private Sub chkPaid_Click()
If chkPaid = True Then ' if it's selected it equals true or -1
chkPartial_Paid = False
Else
chkPartial_Paid = True
End Sub

'and use this for chkPartial_Paid
Private Sub chkPartial_Paid _Click()
If chkPartial_Paid = True Then ' if it's selected it equeals true or -1
chkPaid = False
Else
chkPaid = True
End Sub
--
Reggie

www.smittysinet.com
----------
"Kufre" <ku*******@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
I need anyone that have done this before to help me. I'm creating a
form in Access, in the form has two two checkbox, checkbox A is paid,
checkbox B is partial_paid. I want the set the checkbox so that if the
user click on checkbox A which is Paid, then checkbox B which is
partial_paid should be disable, visa versa, then if checkbox A which
is Paid is uncheck then checkbox B becomes visible. This is the code
I have so far but when I uncheck checkbox A, checkbox B does not
appear. Please help me.

Private Sub chkPaid_Click()
If chkPaid.Enabled = True Then
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = False

Else
chkPaid.Enabled = False
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = True

Nov 12 '05 #2

P: n/a
You need to check the Value of chkPaid, not its Enabled status. If you can
click it to check/uncheck it, then it is enabled. Also, there is no need to
lock a hidden control. It doesn't hurt anything, it just doesn't accomplish
anything. If the user can't see it, they can't do anything to it. It may
also be nicer for the user to just Enable/Disable (grayed out/not grayed
out) chkPartial_Paid rather than hiding and unhiding it (personal
preference).

If chkPaid = True Then

--
Wayne Morgan
Microsoft Access MVP
"Kufre" <ku*******@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
I need anyone that have done this before to help me. I'm creating a
form in Access, in the form has two two checkbox, checkbox A is paid,
checkbox B is partial_paid. I want the set the checkbox so that if the
user click on checkbox A which is Paid, then checkbox B which is
partial_paid should be disable, visa versa, then if checkbox A which
is Paid is uncheck then checkbox B becomes visible. This is the code
I have so far but when I uncheck checkbox A, checkbox B does not
appear. Please help me.

Private Sub chkPaid_Click()
If chkPaid.Enabled = True Then
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = False

Else
chkPaid.Enabled = False
chkPartial_Paid.Visible = False
chkPartial_Paid.Locked = True

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.