Tomasz
|
| Posted: 10/04/2002, 1:34 AM |
|
Two tables: 'persons' and 'occupations'.
'Persons' is a source for search form, it stores id key from 'occupations'. How to search occupations? The only way i know is to use listobox which can be easily joined with 'occupations'. But i need textbox for this search..
|
|
|
 |
Nicole
|
| Posted: 10/07/2002, 5:52 AM |
|
Tomasz,
Search form can not be connected to db. You can let users to enter persons e,g, name (or any other text type field to search on). Then you should look up corresponding id field from persons table before make search in occupations table.
(I assume that you’re using CCS)
Add id parameter for the occupations table on the grid form, but set Parameter Source Type to Expression and in the Name field enter look up code like:
CCDLookUp(“persons”, “id”, “name_field=”. CCtoSQL(CCGetParam(“name_param”, “”), ccsText))
Leave parameter Default Value empty.
|
|
|
 |
Tomasz
|
| Posted: 10/08/2002, 6:35 AM |
|
Nicole,
problem is a little bit more complicated, I'm using CC
|
|
|
 |
Nicole
|
| Posted: 10/09/2002, 7:04 AM |
|
Tomasz,
In this case you should build Where clause on fly in the form Open event and (again) use DLookUp() function to retrieve corresponding “id” value. Then out it into Where. Here is the example:
if (get_param("name_param") != "")
{
//retrieve id field value
$id = DLookUp("persons", "id", "name_field=". ToSQL(get_param("name_param"), "Text"));
//build Where clause
if ($sWhere == "")
$sWhere = " where id_field=". $id;
else
$sWhere .= " and id_field=". $id;
}
|
|
|
 |
Tomasz
|
| Posted: 10/09/2002, 8:04 AM |
|
Nicole,
Today morning probelm was solved with CC support help.
simply method is:
1. create custom SQL for grid joining 2 tables
2. select field from joined table to display occupations
3. set input to the same field (text type)
4. set the same name for textbox in search form
anyway, thank you for your answers
|
|
|
 |
|