Form open or closed to define search

N

nybaseball22

Hello. I have 2 tabular forms that are very similar. At the end of
each record, there is a button that opens a form of detail about the
record. The query that the second form uses is setup to pull its
information from whatever record I click.

Example: I entered this string in one of the query fields - [Forms]!
[SomeForm]![SomeField]

I want to have one form open from both of my tab forms. Because the
tab forms have different names, I am forced to create 2 queries and 2
detail forms. Is there a way to have the query focus on only the form
that is open? I want to have only 1 detail form, but I don't know how
to program the query.

Thanks
 
A

Allen Browne

Unless you actually need different data (tables, fields) for the 2 forms,
you can use the one query to feed both forms.

Just open the 2nd form in design view, and change its RecordSource property
to the name of the query that does what you want.
 
N

nybaseball22

Thank you Allen. I actually want to feed that query with 2 different
strings. The problem I have is not the detail form, but the query
that feeds the detail form has in the string the form name where the
information comes from. Here is an example:

I have 2 tab forms. FormA and FormB. They are very somilar and
contain a great deal of the same information. At the end of each
record, there is a button. When clicked, this button opens a detail
form. This detail form is fed by a query that has 2 strings: [Forms]!
[FormA]![AnyField] and [Forms]![FormA]![AnyOtherField]. The other
detail form is identical to this one, but it is fed by a query that
has 2 strings: [Forms]![FormB]![AnyField] and [Forms]![FormB]!
[AnyOtherField]. The field names are the same on FormA and Form B. I
want to know if I can code the query that feeds the detail form with
something like [Forms]![FormA]![AnyField] OR [Forms]![FormB]!
[AnyField]. I have tried this, but when I execute it, it pops up for
information on the form that is not open. Is there a way to say, if
this form is not open, use the other form for info?

Thanks again.
 
A

Allen Browne

Well, if your query contains a literal reference to a form, it cannot at the
same time contain a literal reference to a different form.

There are probably better ways to design the query so it does not depend on
the form. Not sure if this kind of thing would be useful:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
 

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