Checkbox code problem

K

Kufre

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
 
P

Pavel Romashkin

It is not totally clear what settings should Partial_Paid assume if Paid
is clicked repetedly. Try this though:

Private Sub chkPaid_Click()
Me.chkPartial_Paid.Visible = Not Me.chkPaid
end

You can add code to set the value as you wish.
Pavel
 
G

Graham Mandeno

Use the AfterUpdate property of chkPaid, not the Click property:

chkPartial_Paid.Visible = Not chkPaid.Value

You don't need to change the Locked property. If the checkbox is invisible
then nobody can change it anyway.

You should also put this line of code in your Form_Current event procedure,
so the checkbox gets hidden/shown as you navigate between records.
 
T

TC

You should use an option button group (not two independent checkboxes) to
represent an either/or choice. Then Access will automatically clear the
"other" selection, when the user selects either option.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top