J
Jon A
I am building a database for inspectors to record the
results of their inspections. We want to use the information
to gather metrics about Quality Factors we have defined.
When the Inspector logs the result of the inspection and
clicks on the DONE button, then if the inspection result was
FAIL, then that's where we need to collect the Quality
Factors.
Because each inspected Item has a different set of Quality
Factors, what I am trying to do is use a single form. Based
on the type of Item, the code looks up the Quality Factors
and builds a form dynamically - each Quality Factor is
placed as a Checkbox on the form.
Then the Inspector checks the Quality Factors that apply to
the inspection and closes the form.
After the form closes, I have the code open it back up in
Design view and remove the checkboxes, then save the 'blank'
form.
Everything works OK except for the deleting of the
checkboxes. The code deletes every other checkbox. For
example, I set up test Quality Factors such as QF-01 through
QF-14. When I ran the code, they were all added to the form
and I was able to select them and save the selections to the
database. But the code below deleted only the ODD-NUMBERED
checkboxes and left the even-numbered ones.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Here is the code:
Public Sub BlankQualityFactorsForm()
'This procedure will open the frm_CollectQualityFactors
'form and remove the checkboxes that were placed on the
'form. This will make the form 'blank' in terms of
'checkboxes, so that we can build the form again for
'the next inspection.
Dim intControls As Integer
Dim ctlControl As Control
Dim frmTheForm As Form
DoCmd.OpenForm "frm_CollectQualityFactors", _
acDesign, , , , acHidden
Set frmTheForm = Forms![frm_CollectQualityFactors]
intControls = frmTheForm.Count
For Each ctlControl In frmTheForm.Controls
If ctlControl.ControlType = acCheckBox Then
DeleteControl frmTheForm.Name, ctlControl.Name
End If
Next
DoCmd.Close acForm, frmTheForm.Name, acSaveYes
End Sub 'BlankQualityFactorsForm
results of their inspections. We want to use the information
to gather metrics about Quality Factors we have defined.
When the Inspector logs the result of the inspection and
clicks on the DONE button, then if the inspection result was
FAIL, then that's where we need to collect the Quality
Factors.
Because each inspected Item has a different set of Quality
Factors, what I am trying to do is use a single form. Based
on the type of Item, the code looks up the Quality Factors
and builds a form dynamically - each Quality Factor is
placed as a Checkbox on the form.
Then the Inspector checks the Quality Factors that apply to
the inspection and closes the form.
After the form closes, I have the code open it back up in
Design view and remove the checkboxes, then save the 'blank'
form.
Everything works OK except for the deleting of the
checkboxes. The code deletes every other checkbox. For
example, I set up test Quality Factors such as QF-01 through
QF-14. When I ran the code, they were all added to the form
and I was able to select them and save the selections to the
database. But the code below deleted only the ODD-NUMBERED
checkboxes and left the even-numbered ones.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Here is the code:
Public Sub BlankQualityFactorsForm()
'This procedure will open the frm_CollectQualityFactors
'form and remove the checkboxes that were placed on the
'form. This will make the form 'blank' in terms of
'checkboxes, so that we can build the form again for
'the next inspection.
Dim intControls As Integer
Dim ctlControl As Control
Dim frmTheForm As Form
DoCmd.OpenForm "frm_CollectQualityFactors", _
acDesign, , , , acHidden
Set frmTheForm = Forms![frm_CollectQualityFactors]
intControls = frmTheForm.Count
For Each ctlControl In frmTheForm.Controls
If ctlControl.ControlType = acCheckBox Then
DeleteControl frmTheForm.Name, ctlControl.Name
End If
Next
DoCmd.Close acForm, frmTheForm.Name, acSaveYes
End Sub 'BlankQualityFactorsForm