Command button and subform

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

Guest

In my form I have a field call Language from TblDispatch
, then
created a command button to run a query. This query also lives inside a
subform on the form that supposed to update itself as the query runs.

The query consist of two tables, my text string TblLanguage (only field is
language) and the TblInterpreter (contact Info). The current criteria is to
type in the County and in return that filters to my *counties* interpreters
only. The query runs fine indepently but running inside the subform there is
no results.
 
AbstractGofer said:
In my form I have a field call Language from TblDispatch
, then
created a command button to run a query. This query also lives inside a
subform on the form that supposed to update itself as the query runs.

The query consist of two tables, my text string TblLanguage (only field is
language) and the TblInterpreter (contact Info). The current criteria is to
type in the County and in return that filters to my *counties* interpreters
only. The query runs fine indepently but running inside the subform there is
no results.


What I suggest (to simplify things) is to first set up a subQuery under
your main Query to verify that you get the right results, then use the
two Queries as bases for the Form and subForm.

Ignoring [TblDispatch], which apparently isn't involved in the Form, I
set up these two Queries:

[Q_Language]:

SELECT TblLanguage.TblLanguageID,
TblLanguage.TblLanguage
FROM TblLanguage
ORDER BY TblLanguage.TblLanguage;


[Q_Interpreter]:

SELECT TblInterpreter.TblInterpreterID,
TblInterpreter.Name, TblInterpreter.TblLanguageID
FROM TblInterpreter;

Also, put some sample data into your Tables; for example like these:

TblLanguageID TblLanguage
------------- -----------
1 Walloon
2 Tagalog
3 English
4 Quechua

TblInterpreterID Name TblLanguageID
---------------- ---------- -------------
1 Jim 2
2 Aquendolyn 4
3 Aquendolyn 2
4 Jim 1
5 Aquendolyn 3



If you set up Queries like mine, you can link them as follows:
- Open [Q_Language] in Query Design View
- Right-click in the upper part of the window and select Properties
- Set the Subdatasheet Name = "Query.Q_Interpreter"
- Set the Link Child Fields = "tblLanguageID"
- Set the Link Master Fields = "tblLanguageID"
- Save the Query and change to Query Datasheet View to test it.

For example, clicking on the "+" beside Tagalog should display both
[Q_Interpreter] records in a subdatasheet.

If the test works, then set up two Forms, one for each Query, then in
the [F_Language] Form, add a subForm control and tell the wizard that
you want to use an existing Form there (specifically, the Form that you
just now created based on [Q_Interpreter]). If you gave the matching
fields matching names, as I did, I think the wizard will guess correctly
which fields you want to link. My subForm worked just fine when I tried it.

Having done that, if you want a sub-subForm showing [TblDispatch]
records, just do the same sort of thing -- link a [Q_Dispatch] Query to
your [Q_Interpreter] Query, and add a subForm control to your
[F_Interpreter] subForm of your [F_Language] Form.

Don't get carried away with sub-sub-subForms, though -- your user's
screen will become cluttered. When I feel a need to have several
levels, I usually just use Query Datasheet Views instead of defining my
own Forms.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Back
Top