Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass an SQL string to filter data to a CR trough VB?

Status
Not open for further replies.

yjoke

Programmer
Feb 14, 2002
26
PT
Hi there. i'm having a problem passing an SQL string in VB to filter data and then display it in a VB Crystal Report. Can 'u help me on this? I really need to know how to implement this.

Thank 'u all for your time on this.
 
You're not providing much info. What integration method are you using, are you replacing the entire SQL statement of the report, the WHERE clause, or filling parameters?
 
what i'm trying to do is something like this:

i have a filter form in witch the user chooses the client number (<, =, >) or the clients car license plate (<, =, >)

depending on witch search the user chooses (client number, license plate) an SQL statement is generated only showing the filtered files on the CR.

the SQL statement that allows the viewing of the data is the following:

SELECT
Veiculo.veic_matricula, Veiculo.veic_nquadro,
Modelo.model_nome,
Marca.marca_nome,
Versao.versao_nome,
CLMES.NOME
FROM
TESTES.dbo.Veiculo Veiculo,
TESTES.dbo.Modelo Modelo,
TESTES.dbo.Marca Marca,
TESTES.dbo.Versao Versao,
TESTES.dbo.CLMES CLMES
WHERE
Veiculo.veic_modeloID = Modelo.model_id AND
Veiculo.veic_marcaID = Marca.marca_id AND
Veiculo.veic_versaoID = Versao.versao_id AND
Veiculo.veic_proprietarioID = CLMES.CLIENTE

the code that i'm using is:

Private Sub cmdVeicBusca_Click(Index As Integer)

Select Case cmdVeicBusca(Index).Value = True
Case Index = 0:
strSQLveic = &quot;SELECT &quot; & _
&quot;Veiculo.veic_matricula, Veiculo.veic_nquadro, Modelo.model_nome, Marca.marca_nome,&quot; & _
&quot;Versao.versao_nome, CLMES.NOME &quot; & _
&quot;From &quot; & _
&quot;TESTES.dbo.Veiculo Veiculo, TESTES.dbo.Modelo Modelo, TESTES.dbo.Marca Marca, &quot; & _
&quot;TESTES.dbo.Versao Versao, TESTES.dbo.CLMES CLMES &quot; & _
&quot;Where &quot; & _
&quot;Veiculo.veic_modeloID = Modelo.model_id AND Veiculo.veic_marcaID = Marca.marca_id AND &quot; & _
&quot;Veiculo.veic_versaoID = Versao.versao_id AND Veiculo.veic_proprietarioID = CLMES.CLIENTE&quot;
strCLTveic = &quot;&quot;

If Len(Trim(nbxVeicLmtInf(0).Text)) > 0 Then
If optVeicClienteLI(0).Value = True Then
Operador = &quot;>&quot;
ElseIf optVeicClienteLI(1).Value = True Then
Operador = &quot;=&quot;
Else
Operador = &quot;<&quot;
End If
strCLTveic = &quot; and veic_proprietarioID&quot; & Operador & nbxVeicLmtInf(0).Text
End If

strSQLveic = strSQLveic + strCLTveic
crVeiculo.SQLQueryString = strSQLveic
AbrirReportVeiculo
End Select

End Sub


Sub AbrirReportVeiculo()
ReportVeiculo.Database.LogOnServer &quot;p2ssql.dll&quot;, &quot;Sql2000&quot;, &quot;TESTES&quot;, &quot;agenda&quot;, &quot;testes&quot;
frmCRViewer.CRViewer1.ReportSource = ReportVeiculo
frmCRViewer.CRViewer1.ViewReport
frmCRViewer.Caption = &quot;Veiculo Report&quot;
BotoesImpressao
frmCRViewer.cmdVeicPrint.Visible = True
frmCRViewer.Show vbModal
End Sub


the statement hasn't started working yet.
can anyone tell me how to pass the SQL statment to the CR??
It's extremely URGENT !!

Thank 'u all...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top