USANDO O JOIN

HELDERANGEL 07/08/2009 13:17:55
#319209
Mesmo assim continua dando o mesmo erro. E não consigo achar onde está o erro da sintaxe.
RCMRO 07/08/2009 19:54:11
#319255
O banco é ACCESS?

Para poder te ajudar, me manda os tipos das colunas envolvidas (INT, CHAR, etc):
TBITENSSAI.ISNF_EMPRESA, TBSAIDAS.SNF_EMPRESA, TBCLIENTES.CLI_EMPRESA, TBITENSSAI.ISNF_NOTA, TBSAIDAS.SNF_NOTA, TBITENSSAI.ISNF_SERIE, TBSAIDAS.SNF_SERIE, TBSAIDAS.CLI_CODIGO, TBSAIDAS.SNF_CLIENTE, TBMUNICIPIOS.MUN_CODIGO, TBCLIENTES.CLI_MUNICIPIO. TBSAIDAS.SNF_DT_EMISSAO. TBSAIDAS.SNF_ATENDIMENTO, TBSAIDAS.SNF_COND_PAGTO.

Aproveita e manda o PRINT do valor do [Ô]sqlstr[Ô] até o momento do erro.

Abraços

RCMRO 11/08/2009 22:14:39
#319625
Cara,

Fazia tempo que eu não lidava com as peculiaridades do ACCESS mas, ai vai o código correto.
Só para ter uma idéia do que estava acontecendo, ele precisa abrir e fechar uns parenteses quando faz uma instrução cruzando várias tabelas.
Enfim, acho que agora funciona. Testei aqui substituindo os valores das variáveis e funcionou. Só fica esperto com o [Ô]txtCidade.Text[Ô] pois o conteúdo tem que ser numérico e não TEXTO. Se o conteúdo for algo assim: [Ô]0289 São Paulo[Ô], precida fazer o LEFT$(txtCidade.Text,4).
Outra coisa... Apaga a mensagem que tem o Banco de Dados para DOWNLOAD. é mais seguro com os dados que existem

strsql = [Ô]SELECT TBSAIDAS.*, TBITENSSAI.*, TBPRODUTOS.*, TBMUNICIPIOS.MUN_CODIGO,[Ô]
strsql = strsql & [Ô] TBMUNICIPIOS.MUN_NOME FROM ((TBSAIDAS[Ô]
strsql = strsql & [Ô] INNER JOIN TBITENSSAI ON TBITENSSAI.ISNF_EMPRESA = TBSAIDAS.SNF_EMPRESA[Ô]
strsql = strsql & [Ô] AND TBITENSSAI.ISNF_NOTA = TBSAIDAS.SNF_NOTA AND TBITENSSAI.ISNF_SERIE = TBSAIDAS.SNF_SERIE)[Ô]
strsql = strsql & [Ô] INNER JOIN TBCLIENTES ON TBCLIENTES.CLI_EMPRESA = TBSAIDAS.SNF_EMPRESA[Ô]
strsql = strsql & [Ô] AND TBCLIENTES.CLI_CODIGO = TBSAIDAS.SNF_CLIENTE)[Ô]
strsql = strsql & [Ô] INNER JOIN TBMUNICIPIOS ON TBMUNICIPIOS.MUN_CODIGO = TBCLIENTES.CLI_MUNICIPIO[Ô]
strsql = strsql & [Ô] WHERE TBSAIDAS.SNF_EMPRESA = [ô][Ô] & EmpPadrao & [Ô][ô][Ô]
strsql = strsql & [Ô] AND TBSAIDAS.SNF_DT_EMISSAO >= #[Ô] & Format(Now, [Ô]m/d/yyyy[Ô]) & [Ô]#[Ô]
strsql = strsql & [Ô] AND TBSAIDAS.SNF_DT_EMISSAO <= #[Ô] & Format(Now, [Ô]m/d/yyyy[Ô]) & [Ô]#[Ô]
If optVendedor.Value = True Then
strsql = strsql & [Ô] AND TBSAIDAS.SNF_ATENDIMENTO = [ô]V[ô][Ô]
ElseIf optRepresentante.Value = True Then
strsql = strsql & [Ô] AND TBSAIDAS.SNF_ATENDIMENTO = [ô]R[ô][Ô]
End If
If optAntecipado.Value = True Then
strsql = strsql & [Ô] AND TBSAIDAS.SNF_COND_PAGTO = [Ô] & CondAntecipado
ElseIf optPrazo.Value = True Then
strsql = strsql & [Ô] AND TBSAIDAS.SNF_COND_PAGTO <> [Ô] & CondAntecipado
End If
If txtCidade <> [Ô]T[Ô] Then
strsql = strsql & [Ô] AND TBCLIENTES.CLI_MUNICIPIO = [Ô] & txtCidade.Text
End If
strsql = strsql & [Ô] ORDER BY MUN_NOME, MUN_CODIGO, CLI_UF, ISNF_DT_EMISSAO, ISNF_NOTA, ISNF_SERIE, ISNF_PRODUTO[Ô]
HELDERANGEL 12/08/2009 09:56:30
#319649
RCMRO, valeu, vou fazer o teste aqui e te retorno e valeu pelo toque em relação ao banco de dados
HELDERANGEL 13/08/2009 15:42:39
#319782
RMCRO, deu certinho o join,valeu mesmo. Só uma pergunta, como faço para tirar o link para o banco de dados acima?
RCMRO 13/08/2009 21:55:20
#319827
Aperta no X que tem no inicio do registro em que passou o banco. Só funciona logado.
Não esquece de encerrar e tópico e pontuar.

Boa sorte.
Precisando de algo em SQL, estamos aqui.
Página 2 de 2 [16 registro(s)]
Tópico encerrado , respostas não são mais permitidas