Report Where Condition

  • Thread starter Thread starter António Castro Caldas
  • Start date Start date
A

António Castro Caldas

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 by
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

Anyone?
Thanks
Antonio
 
António Castro Caldas said:
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 by 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

Anyone?
Thanks
Antonio

Put Condicao in the WHERE argument, not the FilterName argument (one more comma
to the right).
 
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 by
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

Anyone?
Thanks
Antonio

Answered elsewhere.
Please do not multi-post. If you feel you must post the same question
to more than one newsgroup (and it's seldom necessary), cross-post by
adding each additional newsgroup in the To Newsgroups: box, separated
by a comma.

This way an answer in one newsgroup will be seen in each of the
others. More readers will see the response and learn, and less time
will be spent on duplicate answers.

See Netiquette at http://www.mvps.org/access

It's a great site to visit anyway.
 
Are you certain that [ClientId] in the If...Then is in fact Null? Also,
try adding
MsgBox(Condicao)
Stop
to one of the Report Events. This will cause a MsgBox to appear with the
value in the where statement and will confirm the value being passed.
 
Back
Top