Applyfilter issue

  • Thread starter Thread starter Sailor
  • Start date Start date
S

Sailor

Using the following code, I want to apply a filter to an open form to lookup
a value entered by the operator in the header of the form:

Dim CNUM As Long

On Error GoTo errh1

If IsNull([CMPNum]) Or [CMPNum] = "" Then
Exit Sub
End If
CNUM = [CMPNum]

DoCmd.ApplyFilter "CMP-Action lookup filter", "[Complaint_Number] = " & CNUM

The saved filter is a query containing 4 tables, one of which has the field
Complaint_Number defined. When the ApplyFilter code executes, it displays a
message box "Enter parameter value" asking for the Complaint_Number.

Why is the message box appearing?

Thanks for your help!

Sailor
 
Thanks for the prompt reply.

Me.Filter results in "Invalid Use of Property" message at compile with the
work Filter highlighted. Could there be a problem with the references?

Sailor

Alex Dybenko said:
Hi,
try to use:
me.Filter= "[Complaint_Number] = " & CNUM
me.FilterOn=true

instead of DoCmd.ApplyFilter

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Sailor said:
Using the following code, I want to apply a filter to an open form to
lookup
a value entered by the operator in the header of the form:

Dim CNUM As Long

On Error GoTo errh1

If IsNull([CMPNum]) Or [CMPNum] = "" Then
Exit Sub
End If
CNUM = [CMPNum]

DoCmd.ApplyFilter "CMP-Action lookup filter", "[Complaint_Number] = " &
CNUM

The saved filter is a query containing 4 tables, one of which has the
field
Complaint_Number defined. When the ApplyFilter code executes, it displays
a
message box "Enter parameter value" asking for the Complaint_Number.

Why is the message box appearing?

Thanks for your help!

Sailor
 
Hi,
yes, this quite strange error. Try to comment out these lines and then
compile the project, perhaps there is some other error as well. And of
course check that all references in place

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Sailor said:
Thanks for the prompt reply.

Me.Filter results in "Invalid Use of Property" message at compile with the
work Filter highlighted. Could there be a problem with the references?

Sailor

Alex Dybenko said:
Hi,
try to use:
me.Filter= "[Complaint_Number] = " & CNUM
me.FilterOn=true

instead of DoCmd.ApplyFilter

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Sailor said:
Using the following code, I want to apply a filter to an open form to
lookup
a value entered by the operator in the header of the form:

Dim CNUM As Long

On Error GoTo errh1

If IsNull([CMPNum]) Or [CMPNum] = "" Then
Exit Sub
End If
CNUM = [CMPNum]

DoCmd.ApplyFilter "CMP-Action lookup filter", "[Complaint_Number] = "
&
CNUM

The saved filter is a query containing 4 tables, one of which has the
field
Complaint_Number defined. When the ApplyFilter code executes, it
displays
a
message box "Enter parameter value" asking for the Complaint_Number.

Why is the message box appearing?

Thanks for your help!

Sailor
 
Back
Top