Form reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In a query you can specify a control by the syntax:
forms![formname]![fieldname]
I have two identical forms, except one is for data entry only. They use the
same query as the source on a combo box. The problem is the form names are
not the same obviously so this doesn't work unless you call a new query and
change the reference. Is there a way round this? In code you can use the Me!
parameter instead of naming the form but this doesn't appear to work in
queries?
Thanks
Sue
 
Sue

I don't understand your situation, but it occurs to me that you could
consider using a single form, rather than two identical forms. If you set
the Data Add property to "yes" as the result of a button click, you could
avoid having to refer to two differently-named forms.

Just one person's opinion

Jeff Boyce
<Access MVP>
 
Nice idea but wouldn't work in this case. Sorry I shouldn't have put
identical really, they have the same fields but one form is linked to table
the other has unbound fields and uses code to populate the table. I am
working on modifying someone else's calendar application and this is how they
had it set up.

Basically what I meant was a combo box uses a query for its criteria, then
on another form I want to use the same query/combo box results again but this
time the form name has changed. I am trying to look up data in a query based
on other data entered on a form ie a user enters a country and then chooses
from a list of dealers that refer to that country which is stored in an
attached table.

I have done it by just making a copy of the query and changing the form name
in the where criteria but I just wandered if there was another way of
refering to a control on a form without having to specify the form name (like
you can in code with the me![fieldname]). Maybe with sql instead of a query
or code? I presume you could build the query in code and pass it me!fieldname
as the parameter but I am not very experienced at programming. Just trying to
learn more by asking questions really...

Thanks
Sue

Jeff Boyce said:
Sue

I don't understand your situation, but it occurs to me that you could
consider using a single form, rather than two identical forms. If you set
the Data Add property to "yes" as the result of a button click, you could
avoid having to refer to two differently-named forms.

Just one person's opinion

Jeff Boyce
<Access MVP>

SJH said:
In a query you can specify a control by the syntax:
forms![formname]![fieldname]
I have two identical forms, except one is for data entry only. They use the
same query as the source on a combo box. The problem is the form names are
not the same obviously so this doesn't work unless you call a new query and
change the reference. Is there a way round this? In code you can use the Me!
parameter instead of naming the form but this doesn't appear to work in
queries?
Thanks
Sue
 
I can "envision" a way, in code, to build a dynamic SQL statement that uses
Me.Name to provide the name of the form in which the code is running. I
don't think it would be "easier" than just making a copy of the query and
changing the form name in the parameter.

--
Good luck

Jeff Boyce
<Access MVP>

SJH said:
Nice idea but wouldn't work in this case. Sorry I shouldn't have put
identical really, they have the same fields but one form is linked to table
the other has unbound fields and uses code to populate the table. I am
working on modifying someone else's calendar application and this is how they
had it set up.

Basically what I meant was a combo box uses a query for its criteria, then
on another form I want to use the same query/combo box results again but this
time the form name has changed. I am trying to look up data in a query based
on other data entered on a form ie a user enters a country and then chooses
from a list of dealers that refer to that country which is stored in an
attached table.

I have done it by just making a copy of the query and changing the form name
in the where criteria but I just wandered if there was another way of
refering to a control on a form without having to specify the form name (like
you can in code with the me![fieldname]). Maybe with sql instead of a query
or code? I presume you could build the query in code and pass it me!fieldname
as the parameter but I am not very experienced at programming. Just trying to
learn more by asking questions really...

Thanks
Sue

Jeff Boyce said:
Sue

I don't understand your situation, but it occurs to me that you could
consider using a single form, rather than two identical forms. If you set
the Data Add property to "yes" as the result of a button click, you could
avoid having to refer to two differently-named forms.

Just one person's opinion

Jeff Boyce
<Access MVP>

SJH said:
In a query you can specify a control by the syntax:
forms![formname]![fieldname]
I have two identical forms, except one is for data entry only. They
use
the
same query as the source on a combo box. The problem is the form names are
not the same obviously so this doesn't work unless you call a new
query
and
change the reference. Is there a way round this? In code you can use
the
Me!
parameter instead of naming the form but this doesn't appear to work in
queries?
Thanks
Sue
 
Back
Top