Loop through a Control to see its value

A

Angel G

Hi!
I have tried many many ways but I just can't get it to work so any ideas are
welcomed. I have a Tests database that has a Form with a subform in it.
I am trying to search for "Fail" value in a control named "PASS_FAIL" in the
subform named "AMC_ResultsB" . If it finds the control value to be "Fail"
then it should set the value of another control "OverAllPassFail" to "Fail"
(this control is in the main form). This way I ensure that if any test
results failed I can Flag the whole test header as Failed.
Here is the code

OverAllPassFail.Value = "Pass"
Dim cCont As Control
For Each cCont In Me.AMC_ResultsB.Controls
If TypeName(cCont) = "PASS_FAIL" Then
If cCont = "Fail" Then
Me.OverAllPassFail.Value = "Fail"
End If
End If
Next cCont

Perhaps there is a better way to acomplish this?
Thanks in advance!
 
J

John W. Vinson

Hi!
I have tried many many ways but I just can't get it to work so any ideas are
welcomed. I have a Tests database that has a Form with a subform in it.
I am trying to search for "Fail" value in a control named "PASS_FAIL" in the
subform named "AMC_ResultsB" . If it finds the control value to be "Fail"
then it should set the value of another control "OverAllPassFail" to "Fail"
(this control is in the main form). This way I ensure that if any test
results failed I can Flag the whole test header as Failed.
Here is the code

OverAllPassFail.Value = "Pass"
Dim cCont As Control
For Each cCont In Me.AMC_ResultsB.Controls
If TypeName(cCont) = "PASS_FAIL" Then
If cCont = "Fail" Then
Me.OverAllPassFail.Value = "Fail"
End If
End If
Next cCont

Perhaps there is a better way to acomplish this?
Thanks in advance!

Yes.

Data is not stored in subforms. Forms and subforms ARE JUST WINDOWS onto the
data.

Look in the Table instead, using a Query.

John W. Vinson [MVP]
 
J

John W. Vinson

The field (control) "PASS_FAIL" is not stored in a table it is a calculated
field.

And you're looking across multiple records? You'll need a different approach,
then. On the subform there is only ONE PASS_FAIL control, no matter how many
times it's displayed. The data which determines the value in PASS_FAIL does
not exist on the *form*; it exists in your *table*.

You'll need some sort of query (using the same kind of calculation you're now
using to set PASS_FAIL) to search the table for the data needed to make the
pass or fail determination.

John W. Vinson [MVP]
 

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