B
Bill Mitchell
I have created a search query that uses the fields of a
subform as its parameters. I would like this subform to
appear in different places within my database; however,
the parameter fields will have a different names
depending upon where the subform is located. I would
prefer not to have to rewrite my query over and over
again for each instance of the subform using the correct
subform location.
Is it possible to create a function which will return the
full name of the location of my search parameter fields
no matter where the subform is located?
For instance, say the subform is located on the "MAIN"
form and I have called the subform "MAIN: Sub". Assume
also that my search parameter field is called "Parameter".
Ok, the name of my field I would use in my select query
for this would be Forms![MAIN]![MAIN: Sub].form!
[Parameter].
This would work fine. However, if I used the same form
as a subform on some other form which had a different
name (for instance "MAIN2" and I named the subform 'MAIN:
Sub2"), this original select query would no longer work
because the names would be wrong.
I want to come up with a Function that will return the
correct location (e.g., 'Forms![MAIN]![MAIN: Sub].form!')
of the search parameter fields no matter where they are
located and then use that function in my query so one
query works everywhere.
So, for instance, if I created a Function called
FormLocation() that represented wherever my search
parameter fields are located, I could us FormLocation()
in my search query like FormLocation()&""&[Parameter]&"
Logically, I think this should be possible, but I can't
figure out how to make FormLocation return the name I
want.
Any help out there? Thanks in advance. I hope all that
made sense.
Bill
subform as its parameters. I would like this subform to
appear in different places within my database; however,
the parameter fields will have a different names
depending upon where the subform is located. I would
prefer not to have to rewrite my query over and over
again for each instance of the subform using the correct
subform location.
Is it possible to create a function which will return the
full name of the location of my search parameter fields
no matter where the subform is located?
For instance, say the subform is located on the "MAIN"
form and I have called the subform "MAIN: Sub". Assume
also that my search parameter field is called "Parameter".
Ok, the name of my field I would use in my select query
for this would be Forms![MAIN]![MAIN: Sub].form!
[Parameter].
This would work fine. However, if I used the same form
as a subform on some other form which had a different
name (for instance "MAIN2" and I named the subform 'MAIN:
Sub2"), this original select query would no longer work
because the names would be wrong.
I want to come up with a Function that will return the
correct location (e.g., 'Forms![MAIN]![MAIN: Sub].form!')
of the search parameter fields no matter where they are
located and then use that function in my query so one
query works everywhere.
So, for instance, if I created a Function called
FormLocation() that represented wherever my search
parameter fields are located, I could us FormLocation()
in my search query like FormLocation()&""&[Parameter]&"
Logically, I think this should be possible, but I can't
figure out how to make FormLocation return the name I
want.
Any help out there? Thanks in advance. I hope all that
made sense.
Bill