applying a filter to report

smig

Registered User.
Local time
Today, 21:01
Joined
Nov 25, 2009
Messages
2,209
I'm trying to apply a filter to report OnOpen. and something is getting wrong :banghead:
I keep getting an error message:
2101 - Setting a wrong property

Code:
Private Sub Report_Open(Cancel As Integer)

Dim strFilter As String

strFilter = "[LakoachID] = " & GetLakoachID() & " OR [LakoachRashiID] = " & GetLakoachID() & " OR [LakoachID] = 11615 "

Me.Filter = strFilter
Me.FilterOn = True

End Sub

the GetLakoachID() exist and return a long var

this will return the same error
strFilter = "[LakoachID] = 11615 OR [LakoachRashiID] = 11615 OR [LakoachID] = 11615 "
 
You have used the same field twice
Code:
strFilter = "[LakoachID] = 11615 OR [LakoachRashiID] = 11615 [B][COLOR="Red"]OR [LakoachID] = 11615 [/COLOR][/B]"

Also FWIW, you have a space at the end & the [] aren't required ...but neither are causing any issues here
 
are both [LakoachID] and [LakoachRashiID] defined as numeric fields at that table level?
 
You have used the same field twice
Code:
strFilter = "[LakoachID] = 11615 OR [LakoachRashiID] = 11615 [B][COLOR="Red"]OR [LakoachID] = 11615 [/COLOR][/B]"

Also FWIW, you have a space at the end & the [] aren't required ...but neither are causing any issues here

I know i used the same ID twice.
It was just for a test

I also tried without the []
 
What is the code for the function GetLakoachID?

Also perhaps you have some corruption. Try decompiling your DB
 
even if I try Me.Filter = "" I get the same error :(
 
Agree, apply filter in OpenReport method instead of trying to filter report in Open event.
 
I can't use the Docmd.OpenReport,as this is a Sub report
 
If nothing works I'll modify the recordSource instead
 
Try to use the master/child to link it to the main report or apply the where clause to its record source.
 
Compacting rarely helps with this type of issue.
Decompiling often works which is why I suggested that!

I also asked about your function
 
In your Subreport property sheet, have you manually cleared the filter? Have you also manually set the "Filter On Load" to"NO"
 

Users who are viewing this thread

Back
Top Bottom