Erro 2447 invalid use of operator...

R

raja07

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
 
K

Ken Snell \(MVP\)

Slight modification (added Form to the subform portion):

If Forms![monitor_ib contact master].Controls(intControl).Value =
Forms![monitor_ib contact
master].Controls("monitor_subform").Form.Controls(intControl).Value Then
 
D

Douglas J. Steele

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
 
R

raja07

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


Douglas J. Steele said:
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!)


raja07 said:
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
 
R

raja07

Hi Ken, thanks for your response
i am still getting the same error message. to give you a bit of background i
created two identical forms linked to two different tables and set their tab
indexes exactly the same. i did have the same concerns that Douglas mentioned
below but i figured i'll do trial and error until i get it to work. this is
the code that i am working with to check the values of each control in the
two forms. let me know what your thoughts are...runs on current. thanks
'Declare variables
Dim intC As Integer
Dim intControl As Integer

'Go through all textboxes to check if their values match those in the
subform
For intC = 0 To 57 'There are 59 textboxes
intControl = intC * 2 'Indexes of textboxes are even numbers from
0 to 118

' if values in corresponding fields match
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


Ken Snell (MVP) said:
Slight modification (added Form to the subform portion):

If Forms![monitor_ib contact master].Controls(intControl).Value =
Forms![monitor_ib contact
master].Controls("monitor_subform").Form.Controls(intControl).Value Then


--

Ken Snell
<MS ACCESS MVP>



raja07 said:
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
 
R

raja07

by the way i did notice when i place my cursor over intcontrol for the form
it's 0 but it says "empty" for intcontrol subform. is this significant?
--
raj


Douglas J. Steele said:
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!)


raja07 said:
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
 
D

Douglas J. Steele

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


Douglas J. Steele said:
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!)


raja07 said:
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
 
R

raja07

i need to monitor when someone changes a record in the master file. so i set
the "after update" property of the main form to append the record to a temp
table that the subform is reading. now i need to compare the two tables to
see what values have changed and write the changed values to a reporting
table. thanks for all of your help!
--
raj


Douglas J. Steele said:
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


Douglas J. Steele said:
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
 
D

Douglas J. Steele

Take a look at Allen Browne's Creating an Audit Log
http://www.allenbrowne.com/AppAudit.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


raja07 said:
i need to monitor when someone changes a record in the master file. so i
set
the "after update" property of the main form to append the record to a
temp
table that the subform is reading. now i need to compare the two tables to
see what values have changed and write the changed values to a reporting
table. thanks for all of your help!
--
raj


Douglas J. Steele said:
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
 

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