Fórum Look Field #154489
12/04/2003
0
Eu tenho as Seguintes Tabelas:
Fornecedor -Catalogo - Produto
O Produto esta ligado ao Catalogo pelo campo cod_catalogo
e o Catalogo esta ligado ao Fornecedor pelo Cod_Fornecedor
Eu fiz uma Consulta que retorna o Nome do produto( Tabela Produto) e o NOme do Fornecedor (Tabela Fornecedor). Como faço para no DbGrid que tem como datasource o DsProduto ter um field que mostre o fornecedor que retornou da minha consulta sql??
Eu sei que tenho que usar o Look Up Field mas nao sei como.
Obrigado.
Fornecedor -Catalogo - Produto
O Produto esta ligado ao Catalogo pelo campo cod_catalogo
e o Catalogo esta ligado ao Fornecedor pelo Cod_Fornecedor
Eu fiz uma Consulta que retorna o Nome do produto( Tabela Produto) e o NOme do Fornecedor (Tabela Fornecedor). Como faço para no DbGrid que tem como datasource o DsProduto ter um field que mostre o fornecedor que retornou da minha consulta sql??
Eu sei que tenho que usar o Look Up Field mas nao sei como.
Obrigado.
Michelsp
Curtir tópico
+ 0
Responder
Posts
12/04/2003
Aroldo Zanela
Michel,
Se enrroscar no inglês, me avisa (acho que isso está documentado em português nas 750 dicas de Delphi):
To create a lookup field in the New Field dialog box:
1Enter a name for the lookup field in the Name edit box. Do not enter the name of an existing field.
2Choose a data type for the field from the Type combo box.
3Enter the size of the field in the Size edit box, if appropriate. Size is only relevant for fields of type TStringField, TBytesField, and TVarBytesField.
4Select Lookup in the Field type radio group. Selecting Lookup enables the Dataset and Key Fields combo boxes.
5Choose from the Dataset combo box drop-down list the dataset in which to look up field values. The lookup dataset must be different from the dataset for the field component itself, or a circular reference exception is raised at runtime. Specifying a lookup dataset enables the Lookup Keys and Result Field combo boxes.
6Choose from the Key Fields drop-down list a field in the current dataset for which to match values. To match more than one field, enter field names directly instead of choosing from the drop-down list. Separate multiple field names with semicolons. If you are using more than one field, you must use persistent field components.
7Choose from the Lookup Keys drop-down list a field in the lookup dataset to match against the Source Fields field you specified in step 6. If you specified more than one key field, you must specify the same number of lookup keys. To specify more than one field, enter field names directly, separating multiple field names with semicolons.
8Choose from the Result Field drop-down list a field in the lookup dataset to return as the value of the lookup field you are creating.
Se enrroscar no inglês, me avisa (acho que isso está documentado em português nas 750 dicas de Delphi):
To create a lookup field in the New Field dialog box:
1Enter a name for the lookup field in the Name edit box. Do not enter the name of an existing field.
2Choose a data type for the field from the Type combo box.
3Enter the size of the field in the Size edit box, if appropriate. Size is only relevant for fields of type TStringField, TBytesField, and TVarBytesField.
4Select Lookup in the Field type radio group. Selecting Lookup enables the Dataset and Key Fields combo boxes.
5Choose from the Dataset combo box drop-down list the dataset in which to look up field values. The lookup dataset must be different from the dataset for the field component itself, or a circular reference exception is raised at runtime. Specifying a lookup dataset enables the Lookup Keys and Result Field combo boxes.
6Choose from the Key Fields drop-down list a field in the current dataset for which to match values. To match more than one field, enter field names directly instead of choosing from the drop-down list. Separate multiple field names with semicolons. If you are using more than one field, you must use persistent field components.
7Choose from the Lookup Keys drop-down list a field in the lookup dataset to match against the Source Fields field you specified in step 6. If you specified more than one key field, you must specify the same number of lookup keys. To specify more than one field, enter field names directly, separating multiple field names with semicolons.
8Choose from the Result Field drop-down list a field in the lookup dataset to return as the value of the lookup field you are creating.
Responder
Gostei + 0
12/04/2003
Aroldo Zanela
Achei nas 750 dicas o seguinte:
110 - Inserindo um Combobox num DBGrid
Siga o passo-a-passo abaixo :
1. insira um Datasource, um DBGrid e dois Table´s no form
2. link o Table1 com Datasource1 e DBGrid1
3. defina um banco de dados, uma tabela e ative o Table1
4. defina também para o Table2, mas use uma tabela diferente
5. adicione todos os campos do Table1 através do Fields Editor
6. mude a propriedade Visble para False do campo do Combobox
7. dê um clique com o botão direito do mouse sobre o Fields Editor e escolha New Field...
[b:2d73c085f5]
8. especifique os parametros para o novo campo
a) Name: <algum nome>
b) Type: <tipo do campo>
c) Size: <tamanho>
d) Field type: Lookup
e) Key Field: <campo que receberá o valor escolhido no combobox&
f) DataSet: Table2
g) LookUpKeys: <campo listado no combo>
h) Result Field: <campo que será mostrado para o usuário no Combobox>
[/b:2d73c085f5]
9. Execute a aplicação.
110 - Inserindo um Combobox num DBGrid
Siga o passo-a-passo abaixo :
1. insira um Datasource, um DBGrid e dois Table´s no form
2. link o Table1 com Datasource1 e DBGrid1
3. defina um banco de dados, uma tabela e ative o Table1
4. defina também para o Table2, mas use uma tabela diferente
5. adicione todos os campos do Table1 através do Fields Editor
6. mude a propriedade Visble para False do campo do Combobox
7. dê um clique com o botão direito do mouse sobre o Fields Editor e escolha New Field...
[b:2d73c085f5]
8. especifique os parametros para o novo campo
a) Name: <algum nome>
b) Type: <tipo do campo>
c) Size: <tamanho>
d) Field type: Lookup
e) Key Field: <campo que receberá o valor escolhido no combobox&
f) DataSet: Table2
g) LookUpKeys: <campo listado no combo>
h) Result Field: <campo que será mostrado para o usuário no Combobox>
[/b:2d73c085f5]
9. Execute a aplicação.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)