GARANTIR DESCONTO

Fórum locate #277927

19/04/2005

0

Olá pessoal estou com o seguinte problema:
Estou querendo gravar os dados abaixo. Antes de gravar ele verifica usando o ´Locate´ para ver se já existe o registro, ou não. Se não existe ele faz um Insert, senão faz apenas um Edit...
No exemplo abaixo estou querendo gravar a pergunta nº 1 na Fábrica = Matriz.
Mas vou ter outras opções de fábrica para a questão nº1, por exemplo:
Posso ter um registro assim: pergunta nº1, fábrica = Filial1 ou pergunta nº1, fábrica = Filial2. Mas não tá dando certo. Quando é um registro que ainda não existe ele grava certo, mas quando deve gravar um novo faz errado. Alguém pode me ajudar???

if (Pesquisa.Locate(´NumPergunta´, ´1´ ,[]) = false) and (Pesquisa.Locate(´Fabrica´, cbFabrica.Text, []) = false) then begin
Pesquisa.Insert;
Pesquisa.FieldByName(´NumPergunta´).AsString := ´1´;
Pesquisa.FieldByName(´Fabrica´).AsString := cbFabrica.Text;
case rg1.ItemIndex of
-1 : Pesquisa.FieldByName(´Nulo´).AsString := Pesquisa.FieldByName(´Nulo´).Value + 1;
0 : Pesquisa.FieldByName(´Bom´).AsString := Pesquisa.FieldByName(´Bom´).Value + 1;
1 : Pesquisa.FieldByName(´Regular´).AsString := Pesquisa.FieldByName(´Regular´).Value + 1;
2 : Pesquisa.FieldByName(´Ruim´).AsString := Pesquisa.FieldByName(´Ruim´).Value + 1;
end;
end else begin
Pesquisa.Edit;
case rg1.ItemIndex of
-1 : Pesquisa.FieldByName(´Nulo´).AsString := Pesquisa.FieldByName(´Nulo´).Value + 1;
0 : Pesquisa.FieldByName(´Bom´).AsString := Pesquisa.FieldByName(´Bom´).Value + 1;
1 : Pesquisa.FieldByName(´Regular´).AsString := Pesquisa.FieldByName(´Regular´).Value + 1;
2 : Pesquisa.FieldByName(´Ruim´).AsString := Pesquisa.FieldByName(´Ruim´).Value + 1;
end;
end;


Daia

Daia

Responder

Posts

19/04/2005

Rjun

Troque

if (Pesquisa.Locate(´NumPergunta´, ´1´ ,[]) = false) and (Pesquisa.Locate(´Fabrica´, cbFabrica.Text, []) = false) then begin


por

if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text,[]) then 
begin



Responder

Gostei + 0

19/04/2005

Rjun

Desculpe-me.

O certo é :

if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text],[]) then 
begin 



Responder

Gostei + 0

19/04/2005

Daia

Troque [quote:c0af446ae3] if (Pesquisa.Locate(´NumPergunta´, ´1´ ,[]) = false) and (Pesquisa.Locate(´Fabrica´, cbFabrica.Text, []) = false) then begin


por

if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text,[]) then 
begin
[/quote:c0af446ae3]


deu erro: not enough actual parameters.
Não a sintaxe do que vc mandou usar.. pode me ajudar???


Responder

Gostei + 0

19/04/2005

Rjun

Repare que no primeiro post eu esqueci um ´]´ que corrigi no segundo. Onde deu erro ?

Outra coisa, coloque o ´not´ na frente do (Pesquisa.Locate.


Responder

Gostei + 0

19/04/2005

Daia

Desculpe-me. O certo é :
if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text],[]) then 
begin 


Sinto muito se eu estou te encomodando é q tô apanhando um monte disse!! Fiz como vc colocou acima, mas deu o mesmo erro denovo e também outro erro: Incompatible Types ´Integer´ and ´TCaption´


Responder

Gostei + 0

19/04/2005

Rjun

De forma alguma você incomada. Gosto de ajudar.

Bom, vamos lá...de que tipo são os campos [b:4c34f5b736]NumPergunta[/b:4c34f5b736] e [b:4c34f5b736]Fabrica[/b:4c34f5b736].


Responder

Gostei + 0

19/04/2005

Daia

NumPergunta é string e fábrica tb...


Responder

Gostei + 0

19/04/2005

Rjun

Coloque o trecho de código que esta dando erro.


Responder

Gostei + 0

19/04/2005

Daia

if not Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text],[]) then

O cursor fica parado no erro entre o [ e ´1´...


Responder

Gostei + 0

19/04/2005

Rjun

Esta faltando parentesis.

Faça isso

if not Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf([´1´, cbFabrica.Text]),[]) then 



Responder

Gostei + 0

19/04/2005

Daia

deu certinho, não sei como te agradecer...
Eu entendi o que estava fazendo errado, mas não tinha noção de como pudesse resolver, não sabia usar o VarArrayOf...
Muito Obrigada...


Responder

Gostei + 0

19/04/2005

Rjun

Se precisar, estamos por aí.


Responder

Gostei + 0

19/04/2005

Leandrosarno

O que é seu banco de dados? Paradox?


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar