Unanswered: Loop through only one checkbox on a form
Hi All! I am somewhat new to access/vba. I am stuck on something and hoping someone on here might be able to help (as I have found several answers on here in the past!)...
I have a form that consists of training material. The form is grouped by a function, which the detail lists the tasks within that function. Whenever a task is modified (via another form only a few folks use), it marks a checkbox (ReviewCheck) as true. This flag the specific line on this form as red and shows all the approvers a change was made. The footer section of the form lists each approvers name, along with a checkbox for each. Once each approver reviews the changes they check their box for approval. I have code in the On Current event that check each specific box by name to determine if all are checked, and if so - it removes the check from the ReviewCheck on the line in the detail.
What I want to do is before the form is closed, check each ReviewCheck record to determine if there are any still checked. If not, a message will pop up that the form has been fully approved and they can print. I have found several posts on how to loop through all checkboxes, but this will not work for me because the approvers will check their boxes true. I just want to loop through the ReviewCheck and determine if any of those specific records are still checked.
I have a close button that I added the following code to, but it does nothing... any help would be MUCH appreciated.
Private Sub Command31_Click()
Dim cCont As Control
Dim cReview As Boolean
cReview = True
For Each cCont In Me.Controls
If TypeName(cCont) = "Review" Then
If Me.ReviewCheck = True Then
cReview = False
If cReview = False Then
MsgBox "Review Complete - please print materials"
'DoCmd.Close acForm, "frm Function Card Approve"
1. Using the function TypeName is this case is not appropriate. TypeName(Something) will never return "Review". TypeName returns a string that represent the Type of a variable, i.e. "Objet", "Byte", "Integer", "Long", "Single", "Double", "Currency", "Decimal", "Date", "String", "Boolean", "Error", "Empty", "Null", "Unknown" or "Nohing".
2. If all the CheckBox controls you want to scan are located in the Form Footer section, you don't need to scan the whole Controls collection of the form, only the Controls collection of that section:
Dim ctl As Control
For Each ctl In Me.Section(acFooter).Controls
If ctl.ControlType = acCheckbox Then
If ctl.Value = False Then
cReview = False