vb code in access to enable the checkbox

How to make vb code in access to enable the checkbox [accepted) if any or all of the following checkboxs [vbp] or [vbv] or [lhi] or [lwt] or [emr] is TRUE.
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
something like this:
if vbp.checked = vbChecked or vbv.checked = vbChecked or lhi.checked = vbChecked or lwt.checked = vbChecked or emr.checked = vbChecked then
accepted.checked = vbChecked
else
accepted.checked = vbUnChecked
end if 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Dear Guy
Thanks I tried the following but did give error message

Private Sub Acceptd_BeforeUpdate(Cancel As Integer)
If Vbp.Checked = vbChecked Or Vbv.Checked = vbChecked Or Lhi.Checked = vbChecked Or Lwt.Checked = vbChecked Or Emr.Checked = vbChecked Then
accepted.Checked = vbChecked
Else
accepted.Checked = vbUnChecked
End If
End Sub
error.png
0
mbizupCommented:
Try this, replacing the names I am using with your actual checkbox names:

 Me.chkaccepted = Me.Checkbox1 + me.Checkbox2 + Me.Checkbox3 + Me.Checkbox4    ' etcetera

Open in new window

0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

mbizupCommented:
The above will check a checkbox named chkAccepted.  If you want to enable it:

Me.chkaccepted.enabled = Me.Checkbox1 + me.Checkbox2 + Me.Checkbox3 + Me.Checkbox4    ' etcetera

Open in new window


This will enable chkAccepted if any are true, and disable it if all are false.
0
mbizupCommented:
>> Private Sub Acceptd_BeforeUpdate(Cancel As Integer)

Just noticed this... The BeforeUpdate event of the Accepted checkbox is NOT the correct place for code that affects the value or enabled properties of the Accepted checkbox.

The code should probably be placed in the AfterUpdate event of all of the other checkboxes, so that any change in the other checkboxes will automatically change the Accepted checkbox as desired.
0
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
it did not work,

to make my question more clear ,i want to have it if any or all of the 5 following check boxes
Vbp
Vbv
Lhi
Lwt
Emr
are TRUE
Then
the check box  Acceptd  shall be TRUE
Else
Acceptd shall be FALSE
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
You should use the after update event of each of the following check boxes  Vbp, Vbv,  Lhi,  Lwt,  Emr

run this

Me.chkaccepted.enabled = (Me.Vbp or Me.Vbv or Me.Lhi or Me.Let or Me.Emr)   

Open in new window




and the form's on current event
 
If not Me.NewRecord then 
    Me.chkaccepted.enabled = (Me.Vbp or me.Vbv or Me.Lhi or Me.Let or Me.Emr) 
End IF

Open in new window


Also set the default value for the 5 check boxes to False.
0
mbizupCommented:
--->>> it did not work,

That doesn't really help.  Did you get an error message (which number/description)?  Incorrect results?  Etc?

Post the code that you tried.

This will *definitely* set the value of the check box to TRUE if any or all of the other checkboxes are checked and False if None are checked, assuming you have the right names:

 Me.Acceptd = Me.Vbp + me.Vbv + Me.Lhi + Me.Emr + Me.Lhw

Open in new window


As I mentioned earlier, the code needs to go in the After Update events of all of the checkboxes that appear on the right of the = sign to set the value of Acceptd when the user changes the value of any of the other checkboxes (not in the Before Update event, as you originally had it).

Also as Boyd Trimmell mentioned, the code should be added to the form's Current Event to set the value of Acceptd as the user navigates between records.
0
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
I've requested that this question be deleted for the following reason:

I trying to shift to share point
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.