Filter problem

  • Thread starter Thread starter Leslie Isaacs
  • Start date Start date
L

Leslie Isaacs

Hello All

I am using A97.
I have the following code behind an option group on a form, but it doesn't
work and when I try to compile I get the message "Method or data member not
found".

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[frm gp bags].Filter = "[destroyed date]is null"
Else
[frm gp bags].Filter = "[destroyed date] is not null"
End If
[frm gp bags].FilterOn = True
End Sub

I can't seem to get this right, so would be very grateful if someone can
help.

Many thanks
Leslie Isacs
 
I am assuming that [Frame4] is an Option Group Frame in [frm gp bags] and
that [frm gp bags] is the current form. There are a couple of problems here.
One is creating the error, the other is improper naming.

[Fram4] should be referenced as [forms]![frm gp bags]![Frame4] and
[frm gp bags] should be referenced as [forms]![frm gp bags]. With that
being said, there are a couple of improvements you can make. If, in fact my
previously stated assumptions are correct, then better coding would be:
Me.Frame4 (Me refers to the current form)
Next, NEVER EVER EVER FOR ANY REASON USE SPACES IN A NAME!!!!

Private Sub Frame4_AfterUpdate()
Me.Filter = Iif(Me.Frame4 = 1, "[destroyed date] is null", _
"[destroyed date]is null")
Me..FilterOn = True
End Sub




Here is new and improved code:
 
Hello Klatuu

Thank you for your reply.

What I should have said is that [frm gp bags] is in fact a subform (which
needs to be in datasheet view) on the main form, and [Frame4] is an Option
Group Frame on the main form. I realise that my object-naming convention has
been poor, but it has improved: this form was created in my early days!

I have amended the code to:

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[Forms]![frm gp bags].Filter = "[destroyed date]is null"
Else
[Forms]![frm gp bags].Filter = "[destroyed date] is not null"
End If
[Forms]![frm gp bags].FilterOn = True
End Sub

but I still get
Runtime error 2450
Access can't find the form 'frm gp bags' referred to in a macro expression
or visual basic code.

Hope you can help.
Many thanks
Les



Klatuu said:
I am assuming that [Frame4] is an Option Group Frame in [frm gp bags] and
that [frm gp bags] is the current form. There are a couple of problems here.
One is creating the error, the other is improper naming.

[Fram4] should be referenced as [forms]![frm gp bags]![Frame4] and
[frm gp bags] should be referenced as [forms]![frm gp bags]. With that
being said, there are a couple of improvements you can make. If, in fact my
previously stated assumptions are correct, then better coding would be:
Me.Frame4 (Me refers to the current form)
Next, NEVER EVER EVER FOR ANY REASON USE SPACES IN A NAME!!!!

Private Sub Frame4_AfterUpdate()
Me.Filter = Iif(Me.Frame4 = 1, "[destroyed date] is null", _
"[destroyed date]is null")
Me..FilterOn = True
End Sub




Here is new and improved code:


Leslie Isaacs said:
Hello All

I am using A97.
I have the following code behind an option group on a form, but it doesn't
work and when I try to compile I get the message "Method or data member not
found".

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[frm gp bags].Filter = "[destroyed date]is null"
Else
[frm gp bags].Filter = "[destroyed date] is not null"
End If
[frm gp bags].FilterOn = True
End Sub

I can't seem to get this right, so would be very grateful if someone can
help.

Many thanks
Leslie Isacs
 
Is [frm gp bags] open, enabled, and visible when this code executes?
Other than that, this is confusing.

Leslie Isaacs said:
Hello Klatuu

Thank you for your reply.

What I should have said is that [frm gp bags] is in fact a subform (which
needs to be in datasheet view) on the main form, and [Frame4] is an Option
Group Frame on the main form. I realise that my object-naming convention has
been poor, but it has improved: this form was created in my early days!

I have amended the code to:

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[Forms]![frm gp bags].Filter = "[destroyed date]is null"
Else
[Forms]![frm gp bags].Filter = "[destroyed date] is not null"
End If
[Forms]![frm gp bags].FilterOn = True
End Sub

but I still get
Runtime error 2450
Access can't find the form 'frm gp bags' referred to in a macro expression
or visual basic code.

Hope you can help.
Many thanks
Les



Klatuu said:
I am assuming that [Frame4] is an Option Group Frame in [frm gp bags] and
that [frm gp bags] is the current form. There are a couple of problems here.
One is creating the error, the other is improper naming.

[Fram4] should be referenced as [forms]![frm gp bags]![Frame4] and
[frm gp bags] should be referenced as [forms]![frm gp bags]. With that
being said, there are a couple of improvements you can make. If, in fact my
previously stated assumptions are correct, then better coding would be:
Me.Frame4 (Me refers to the current form)
Next, NEVER EVER EVER FOR ANY REASON USE SPACES IN A NAME!!!!

Private Sub Frame4_AfterUpdate()
Me.Filter = Iif(Me.Frame4 = 1, "[destroyed date] is null", _
"[destroyed date]is null")
Me..FilterOn = True
End Sub




Here is new and improved code:


Leslie Isaacs said:
Hello All

I am using A97.
I have the following code behind an option group on a form, but it doesn't
work and when I try to compile I get the message "Method or data member not
found".

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[frm gp bags].Filter = "[destroyed date]is null"
Else
[frm gp bags].Filter = "[destroyed date] is not null"
End If
[frm gp bags].FilterOn = True
End Sub

I can't seem to get this right, so would be very grateful if someone can
help.

Many thanks
Leslie Isacs
 
Hello Klatuu

Yes, [frm gp bags] is open, enabled, and visible when this code executes.
Glad it's not just me who's confused - hope you can help though!!

Many thanks
Les


Klatuu said:
Is [frm gp bags] open, enabled, and visible when this code executes?
Other than that, this is confusing.

Leslie Isaacs said:
Hello Klatuu

Thank you for your reply.

What I should have said is that [frm gp bags] is in fact a subform (which
needs to be in datasheet view) on the main form, and [Frame4] is an Option
Group Frame on the main form. I realise that my object-naming convention has
been poor, but it has improved: this form was created in my early days!

I have amended the code to:

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[Forms]![frm gp bags].Filter = "[destroyed date]is null"
Else
[Forms]![frm gp bags].Filter = "[destroyed date] is not null"
End If
[Forms]![frm gp bags].FilterOn = True
End Sub

but I still get
Runtime error 2450
Access can't find the form 'frm gp bags' referred to in a macro expression
or visual basic code.

Hope you can help.
Many thanks
Les



Klatuu said:
I am assuming that [Frame4] is an Option Group Frame in [frm gp bags] and
that [frm gp bags] is the current form. There are a couple of
problems
here.
One is creating the error, the other is improper naming.

[Fram4] should be referenced as [forms]![frm gp bags]![Frame4] and
[frm gp bags] should be referenced as [forms]![frm gp bags]. With that
being said, there are a couple of improvements you can make. If, in
fact
my
previously stated assumptions are correct, then better coding would be:
Me.Frame4 (Me refers to the current form)
Next, NEVER EVER EVER FOR ANY REASON USE SPACES IN A NAME!!!!

Private Sub Frame4_AfterUpdate()
Me.Filter = Iif(Me.Frame4 = 1, "[destroyed date] is null", _
"[destroyed date]is null")
Me..FilterOn = True
End Sub




Here is new and improved code:


:

Hello All

I am using A97.
I have the following code behind an option group on a form, but it doesn't
work and when I try to compile I get the message "Method or data
member
not
found".

Private Sub Frame4_AfterUpdate()
If [Frame4].Value = 1 Then
[frm gp bags].Filter = "[destroyed date]is null"
Else
[frm gp bags].Filter = "[destroyed date] is not null"
End If
[frm gp bags].FilterOn = True
End Sub

I can't seem to get this right, so would be very grateful if someone can
help.

Many thanks
Leslie Isacs
 
Back
Top