Fórum locate #277927
19/04/2005
0
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
Curtir tópico
+ 0Posts
19/04/2005
Rjun
por
if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text,[]) then begin
Gostei + 0
19/04/2005
Rjun
O certo é :
if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text],[]) then begin
Gostei + 0
19/04/2005
Daia
por
if Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf[´1´, cbFabrica.Text,[]) then begin
deu erro: not enough actual parameters.
Não a sintaxe do que vc mandou usar.. pode me ajudar???
Gostei + 0
19/04/2005
Rjun
Outra coisa, coloque o ´not´ na frente do (Pesquisa.Locate.
Gostei + 0
19/04/2005
Daia
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´
Gostei + 0
19/04/2005
Rjun
Bom, vamos lá...de que tipo são os campos [b:4c34f5b736]NumPergunta[/b:4c34f5b736] e [b:4c34f5b736]Fabrica[/b:4c34f5b736].
Gostei + 0
19/04/2005
Daia
Gostei + 0
19/04/2005
Rjun
Gostei + 0
19/04/2005
Daia
O cursor fica parado no erro entre o [ e ´1´...
Gostei + 0
19/04/2005
Rjun
Faça isso
if not Pesquisa.Locate(´NumPergunta;Fabrica´, VarArrayOf([´1´, cbFabrica.Text]),[]) then
Gostei + 0
19/04/2005
Daia
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...
Gostei + 0
19/04/2005
Rjun
Gostei + 0
19/04/2005
Leandrosarno
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)