Trying to Open a Report with a Where Condition...

A

Antonio

Hi,

I'm trying to open a Report on an Open event, through a button in a form.
I'm passing a Where Condition, however, the Report seems to ignore it... It
simply shows all the records existing in the table... The record can be
called through 2 diferent buttons, one of them with no filter (hence the
Condicao Variable):

Private Sub MonthlyReports_Click()
Dim Condicao: Condicao = ""

If Not IsNull(Forms![Propostas]![ClientID]) Then
Condicao = "[ClientID]=" & Forms![Propostas]![ClientID]
End If

DoCmd.OpenReport "FollowUpPropostas", acPreview, Condicao, ,
acWindowNormal

End Sub

Is this something to do with the SQL in the Report? It's quite simple, it's
just a Select to have the fields I want in the report...

Anyone?
Thanks
Antonio
 
F

fredg

Hi,

I'm trying to open a Report on an Open event, through a button in a form.
I'm passing a Where Condition, however, the Report seems to ignore it... It
simply shows all the records existing in the table... The record can be
called through 2 diferent buttons, one of them with no filter (hence the
Condicao Variable):

Private Sub MonthlyReports_Click()
Dim Condicao: Condicao = ""

If Not IsNull(Forms![Propostas]![ClientID]) Then
Condicao = "[ClientID]=" & Forms![Propostas]![ClientID]
End If

DoCmd.OpenReport "FollowUpPropostas", acPreview, Condicao, ,
acWindowNormal

End Sub

Is this something to do with the SQL in the Report? It's quite simple, it's
just a Select to have the fields I want in the report...

Anyone?
Thanks
Antonio

The Where clause variable must be a String.
The Where clause is the 4th argument, not the 3rd, in the OpenReport
method.
The WindowMode is the 5th argument, not the 6th.

Dim Condicao as String
If Not IsNull(Forms![Propostas]![ClientID]) Then
Condicao = "[ClientID]=" & Forms![Propostas]![ClientID]
End If

DoCmd.OpenReport "FollowUpPropostas", acPreview, , Condicao,
acWindowNormal
 
D

Duane Hookom

Asnwered in another news group where you asked the same question. Please
refrain from asking the same question in multiple NGs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top