Expression Builder mid-references objects?

D

DHofer

I used the expression builder to get the fully qualified name of a field
SubformContactId in a subform CLIENTS within a form BIDS to compare with the
equivalent field on the BIDS table and get a condition for an embedded Macro
step:

In left pane:
-Forms
-Loaded Forms
-BIDS
[foldersymbol icon] ClientsBids
In center pane I chose the field I want, Name in Subform is: SubformContactId

Pasting result gives:

[Forms]![BIDS]![CLIENTS3].[Form]![SubformContactId]=[Forms]![BIDS]![Contact
Id]

Error 2950 msg: There is no field named
'Forms!BIDS!Forms!CLIENTS3!SubFormContactId' in the current record.
 
S

Steve Schapel

DHofer,

What is the Event that the macro is being called from? Is it an event
on the BIDS form? Or on the CLIENTS3 subform? Or somewhere else?
 
D

DHofer

The event is the Form On Current event using an Embedded Macro. Each time the
record changes in the parent form I want the matching Contact Id on the
subform to be located. I don't want the forms linked with Link Master Fields
and Link Child Fields.

Steve Schapel said:
DHofer,

What is the Event that the macro is being called from? Is it an event
on the BIDS form? Or on the CLIENTS3 subform? Or somewhere else?

--
Steve Schapel, Microsoft Access MVP
I used the expression builder to get the fully qualified name of a field
SubformContactId in a subform CLIENTS within a form BIDS to compare with the
equivalent field on the BIDS table and get a condition for an embedded Macro
step:

In left pane:
-Forms
-Loaded Forms
-BIDS
[foldersymbol icon] ClientsBids
In center pane I chose the field I want, Name in Subform is: SubformContactId

Pasting result gives:

[Forms]![BIDS]![CLIENTS3].[Form]![SubformContactId]=[Forms]![BIDS]![Contact
Id]

Error 2950 msg: There is no field named
'Forms!BIDS!Forms!CLIENTS3!SubFormContactId' in the current record.
 
S

Steve Schapel

DHofer,

Thanks for the further explanation.

The best syntax for the Condition expression would probably be like this:
[CLIENTS3]![SubformContactId]=[Contact Id]

However, it seems to me that you may have misinterpreted the
meaning/purpose of a macro Condition. I don't think this is applicable
anyway to what you are trying to achieve. You won't be able to "locate"
the matching subform record using a Condition.

Any reason not to use the Link Master Fields and Link Child Fields
properties of the subform?

Perhaps one approach that may work is to use a SetValue action in your
macro to modify the RecordSource of the subform.
 
D

DHofer

Thanks for your reply.

I guess my problem is understanding naming, illustrated by a GoToControl
example. The following works:

GoToControl [CLIENTS3] the subform
GoToControl [SubformContactId] field in subform

The following does not work, gives error 2950:

GoToControl [CLIENTS3]![SubformContactId]

The expression builder gives the following which gives error 2950:

GoToControl Forms![BIDS]![Clients].Form![SubformContactId]

What is the expression builder for?

Dan


Steve Schapel said:
DHofer,

Thanks for the further explanation.

The best syntax for the Condition expression would probably be like this:
[CLIENTS3]![SubformContactId]=[Contact Id]

However, it seems to me that you may have misinterpreted the
meaning/purpose of a macro Condition. I don't think this is applicable
anyway to what you are trying to achieve. You won't be able to "locate"
the matching subform record using a Condition.

Any reason not to use the Link Master Fields and Link Child Fields
properties of the subform?

Perhaps one approach that may work is to use a SetValue action in your
macro to modify the RecordSource of the subform.

--
Steve Schapel, Microsoft Access MVP
The event is the Form On Current event using an Embedded Macro. Each time the
record changes in the parent form I want the matching Contact Id on the
subform to be located. I don't want the forms linked with Link Master Fields
and Link Child Fields.
 
S

Steve Schapel

Dan,

I regret to say that the Expression Builder sometimes is useful and
sometimes not. It has been many years since I used it.

Part of the problem is that the correct syntax depends on your starting
point, and also on where the macro is being called from. So, if you
have a macro that runs on an event on the main form, then with a
GoToControl action you can nominate the name of a subform, as the
subform control is a member of the main form's controls collection. But
if the macro is called from an event on the subform, or if the focus has
already been set to the subform, you can no longer refer to the subform
in your syntax, because from the subform's "point of view" the subform
does not exist, as the subform only exists in the context of the main
form. Sorry it's confusing... you get used to it after a while!
 
D

DHofer

Just found this web site which may help:
http://www.mvps.org/access/forms/frm0031.htm

Steve Schapel said:
Dan,

I regret to say that the Expression Builder sometimes is useful and
sometimes not. It has been many years since I used it.

Part of the problem is that the correct syntax depends on your starting
point, and also on where the macro is being called from. So, if you
have a macro that runs on an event on the main form, then with a
GoToControl action you can nominate the name of a subform, as the
subform control is a member of the main form's controls collection. But
if the macro is called from an event on the subform, or if the focus has
already been set to the subform, you can no longer refer to the subform
in your syntax, because from the subform's "point of view" the subform
does not exist, as the subform only exists in the context of the main
form. Sorry it's confusing... you get used to it after a while!

--
Steve Schapel, Microsoft Access MVP
Thanks for your reply.

I guess my problem is understanding naming, illustrated by a GoToControl
example. The following works:

GoToControl [CLIENTS3] the subform
GoToControl [SubformContactId] field in subform

The following does not work, gives error 2950:

GoToControl [CLIENTS3]![SubformContactId]

The expression builder gives the following which gives error 2950:

GoToControl Forms![BIDS]![Clients].Form![SubformContactId]

What is the expression builder for?
 
S

Steve Schapel

Dan,

Yes, I am familar with that site, and it is a good reference. However,
it is for VBA code, and does not apply to macros. For example, in a
macro, the Me keyword is not recognised.
 

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