Sorry, that doesn't make much more sense to me.
As far as I know, the tab order has no impact on the position in the
Controls collection. And you don't have strictly text boxes on the parent
form: you've got a subform, so there's at least one non text box.
Are the texst boxes on the subform named the same as the text boxes on
the
parent form? If so, try:
Dim ctlCurr As Control
For Each ctlCurr In Forms![monitor_ib contact master].Controls
If TypeOf ctlCurr Is TextBox Then
If ctlCurr.Value = Forms![monitor_ib contact
master]![monitor_subform].Form.Controls(ctlCurr.Name).Value Then
' Do whatever you want when the values are the same
End If
End If
Next ctlCurr
If you really need the control number, try
Dim ctlCurr As Control
Dim lngLoop As Long
For lngLoop = 0 To (Forms![monitor_ib contact master].Controls.Count -
1)
Set ctlCurr = Forms![monitor_ib contact master].Controls(lngLoop)
If TypeOf ctlCurr Is TextBox Then
If ctlCurr.Value = Forms![monitor_ib contact
master]![monitor_subform].Form.Controls(ctlCurr.Name).Value Then
' Do whatever you want when the values are the same
End If
End If
Next lngLoop
How about you explain in words exactly what you're trying to accomplish,
and
someone should be able to offer a suggestion.
Let's start with why are you comparing values from the parent form to
values
on the subform?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
raja07 said:
i guess you are right...because i'm still getting the same error. i have
two
identical forms reading two identical tables. the only controls on both
forms
are text boxes and i set the tab indexes exactly the same for both
forms.
i
did have this same concern that you've mentioned but i'm not sure what
the
answer is. i am attaching the first if statement that i wrote please
see
if
it makes any sense. thanks for your assistance.
Declare variables
Dim intC As Integer
Dim intControl As Integer
'Go through all textboxes to check if their values match those in
the
invisible subform
For intC = 0 To 59 'There are 59 textboxes
intControl = intC * 2 'Indexes of textboxes are even numbers
from
0 to 118
If Forms![monitor_ib contact
master].Controls(intControl).Value
= Forms![monitor_ib contact
master]![monitor_Subform].Form.Controls(incontrol).Value Then
Forms![monitor_ib contact master].Controls(intControl).ForeColor
=
0
Forms![monitor_ib contact master].Controls(intControl).BackColor
=
16777215
--
raj
:
I don't see how that could have worked in previous versions of Access.
Not
every Control has a Value property. For example, label and lines
don't,
yet
each is a member of the Controls collection. That code will error out
for
every control it encounters that doesn't have a Value property.
I also don't understand the point of it. You're trying to see whether
the
value of control 1 on the parent form equals the value of control 1 on
the
subform, then whether the value of control 2 on the parent form equals
the
value of control 2 on the subform and so on. How do you know that it's
legitimate to compare the value of control 1 to control 1: that it's
not
control 1 on the parent form and control 3 on the subform?
In any case, the answer to your specific question is that you need to
look
at the Form object of the subform control:
If Forms![monitor_ib contact master].Controls(intControl).Value =
Forms![monitor_ib contact
master].Controls("monitor_subform").Form.Controls(intControl).Value
Then
or, more simply.
If Forms![monitor_ib contact master].Controls(intControl).Value =
Forms![monitor_ib contact
master]![monitor_subform].Form.Controls(intControl).Value Then
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
i am getting an error invalid use of .(dot) ! or parenthesis from the
following line of code...i am attempting to compare the values of
the
controls on a form to the controls of it's subform by storing the
indexes
in
a variable name "intcontrol". this exact code works in an earlier
version
of
access but i am getting this error in 03 version. any help is
greatly
appreciated. thanks
If Forms![monitor_ib contact master].Controls(intControl).Value =
Forms![monitor_ib contact
master].Controls("monitor_subform").Controls(intControl).Value Then