USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Consulta Sql Com tres Parâmetros
Marcelo(mfc)
RIO DE JANEIRO
RJ - BRASIL
ENUNCIADA !
Postada em 06/12/2006 10:19 hs            
Pessoal,
   Mais uma vez, estou aqui precisando de uma ajuda de vcs.
 
Estou com uma consulta com dois parametros e quero colocar mais um parâmetros,mais não estou conseguindo. Vcs podem me ajudar.
Segue a rotina que estou usando.
 
Private Sub AtualizaGrid()
Dim Parametros As String
Parametros = CboBandeira
Categorias = CboCat
If Parametros = "( Selecione...)" Then
  Parametros = ""
End If
    If DtpInicio > DtpFim Then
        MsgBox "Data Início não pode ser maior Data Fim", vbExclamation, "Pesquisa Oferta"
    Else
pr = ""
If Trim(Parametros) <> "" Then
  pr = " And Folhetos.DescBand = '" & Parametros & "'"
End If
 
Cat = ""
If Trim(Categorias) <> "" Then
  pr = " And Folhetos.Categorias = '" & Categorias & "'"
End If
 
 
 
Set Rs = Banco.OpenRecordset("SELECT * FROM Folhetos Where DtCamp BETWEEN #" & Format(DtpInicio.Value, "YYYY/MM/DD") & "# AND #" & Format(DtpFim.Value, "YYYY/MM/DD") & "#" & pr And cAT)
i = 1
If Rs.EOF Then
    GrdPesquisa.Clear
    Call FormatoGrid
   
    MsgBox "Não existe dados para consultar", vbExclamation, "Consulta Oferta"
   
 Else
Do While Not Rs.EOF
With GrdPesquisa
    .Rows = i + 1
    .TextMatrix(i, 0) = Rs![IdPLu]
    .TextMatrix(i, 1) = Rs![DescPlu]
    .TextMatrix(i, 2) = Rs![DescBand]
    .TextMatrix(i, 3) = Rs![Notab]
    .TextMatrix(i, 4) = Rs![DtCamp]
    .TextMatrix(i, 5) = Rs![CustNetDc1]
    .TextMatrix(i, 6) = Rs![PmzNet]
    .TextMatrix(i, 7) = Rs![PrMedmerc]
    .TextMatrix(i, 8) = Rs![PrOferta]
    .TextMatrix(i, 9) = Rs![Compet]
    .TextMatrix(i, 10) = Rs![PercMgNetDc1]
    .TextMatrix(i, 11) = Rs![Dc2Unid]
    .TextMatrix(i, 12) = Rs![PercMgNetNet]
    .TextMatrix(i, 13) = Rs![QtdVdUnid]
    .TextMatrix(i, 14) = Rs![Dc2Total]
    .TextMatrix(i, 15) = Rs![VlMgNetNet]
    .TextMatrix(i, 16) = Rs![VlVenda]
   
End With
    i = i + 1
    Rs.MoveNext
Loop
 End If
End If
End Sub
Obrigado,
 
 
   
ghost_jlp
Pontos: 2843 Pontos: 2843 Pontos: 2843 Pontos: 2843
SÃO PAULO
SP - BRASIL
Postada em 06/12/2006 10:44 hs            

Tenta assim:

...

Cat = ""
If Trim(Categorias) <> "" Then
  Cat = " And Folhetos.Categorias = '" & Categorias & "'"
End If

Set Rs = Banco.OpenRecordset("SELECT * FROM Folhetos Where DtCamp BETWEEN #" & Format(DtpInicio.Value, "YYYY/MM/DD") & "# AND #" & Format(DtpFim.Value, "YYYY/MM/DD") & "#" & pr & Cat)

at+

     
PH1959
Pontos: 2843
SÃO JOSÉ DOS CAMPOS
SP - BRASIL
ENUNCIADA !
Postada em 06/12/2006 12:03 hs            

selecao="SELECT * FROM Folhetos Where DtCamp BETWEEN #" & Format(DtpInicio.Value, "YYYY/MM/DD") & "# AND #" & Format(DtpFim.Value, "YYYY/MM/DD") & "and folhetos.CAMPOCATEGORIA=" &  cat & "AND folhetos.CAMPOBANDEIRA=" & Cat

Set Rs = Banco.OpenRecordset(selecao, dbopensnapshot)

   
Marcelo(mfc)
RIO DE JANEIRO
RJ - BRASIL
ENUNCIADA !
Postada em 06/12/2006 21:22 hs            
Valeu.. Funcionou.. Obrigado a todos..
 
 
   
Página(s): 1/1    

CyberWEB Network Ltda.    © Copyright 2000-2026   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página