Problems With Filter Syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code but I am doing something wrong with the "if
me.fitler" part of the statemenet since it always comes up with the label New
Activities Report even when it is an Internal Reference. What is wrong with
the syntax?

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If

Thanks
 
I should add that I am testing this in an expression placed in the reports
"On Open". The report is openning from a macro that is filtering the report.
It seems the filter information does not get placed in the filter command
until after so the me.filter = "" when I am testing it. What should I use to
test it after it opens and places a filter on?
 
Perhaps Me.Filter isn't what you think it is. It is possible that the
apostrophes got changed to quotation marks, or that the Parentheses are not
there, or ...

Try adding a debug.print statement, msgbox, or setting a break point on the
code to check the value.

Msgbox "The Filter is " & me.Filter

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If
 
John,

I did make a break point and found out that it contains nothing. Maybe I
need to do this another way. Let me give you more detail.

I have a report that is opening by a macro. The macro opens the report and
sets the filter. I want to change either a text box or a label caption in my
title to say "Internal References". What can I use in the macro after the
report opens to tell it to place the title in the label? I tried SetValue
but that didn't work. I don't know what else I can do. I have about fifteen
macros that open the report and need different titles depending on each macro.

Any help would be greatly appreciated as I have spent too much time of
trying to figure this one out.

Thanks John,

Debra Ann
--
Debra Ann


John Spencer said:
Perhaps Me.Filter isn't what you think it is. It is possible that the
apostrophes got changed to quotation marks, or that the Parentheses are not
there, or ...

Try adding a debug.print statement, msgbox, or setting a break point on the
code to check the value.

Msgbox "The Filter is " & me.Filter

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If


Debra Ann said:
I have the following code but I am doing something wrong with the "if
me.fitler" part of the statemenet since it always comes up with the label
New
Activities Report even when it is an Internal Reference. What is wrong
with
the syntax?

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If

Thanks
 
WHERE are you executing the code? Which event of the report? It could be
as simple as you need to move your code to a different event.

Perhaps the format event of the relevant section - the section that contains
the control lblHeading,


Debra Ann said:
John,

I did make a break point and found out that it contains nothing. Maybe I
need to do this another way. Let me give you more detail.

I have a report that is opening by a macro. The macro opens the report
and
sets the filter. I want to change either a text box or a label caption in
my
title to say "Internal References". What can I use in the macro after the
report opens to tell it to place the title in the label? I tried SetValue
but that didn't work. I don't know what else I can do. I have about
fifteen
macros that open the report and need different titles depending on each
macro.

Any help would be greatly appreciated as I have spent too much time of
trying to figure this one out.

Thanks John,

Debra Ann
--
Debra Ann


John Spencer said:
Perhaps Me.Filter isn't what you think it is. It is possible that the
apostrophes got changed to quotation marks, or that the Parentheses are
not
there, or ...

Try adding a debug.print statement, msgbox, or setting a break point on
the
code to check the value.

Msgbox "The Filter is " & me.Filter

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If


Debra Ann said:
I have the following code but I am doing something wrong with the "if
me.fitler" part of the statemenet since it always comes up with the
label
New
Activities Report even when it is an Internal Reference. What is wrong
with
the syntax?

If Me.Filter = "([Type] = 'IR')" Then
Me.lblHeading.Caption = "Internal References"
Else
Me.lblHeading.Caption = "New Activities Report"
End If

Thanks
 
Back
Top