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

  • Thread starter Thread starter Antonio
  • Start date Start date
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
 
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
 
Asnwered in another news group where you asked the same question. Please
refrain from asking the same question in multiple NGs.
 
Back
Top