Solved

Applyfilter using string variable

Posted on 2008-06-10
4
277 Views
Last Modified: 2013-11-27
I am getting a syntax error on this, and similar versions, please advise.  Thank you.

dim strVal as string
strVal = "Joe Smith"
docmd.applyfilter("filterName"), "fieldName1=" & strVal
0
Comment
Question by:ellenjbr
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 21749120
"fieldName1='" & strVal & "'"
0
 
LVL 12

Assisted Solution

by:koutny
koutny earned 250 total points
ID: 21749383
The syntax error would be caused by wrong calling convention for the ApplyFilter method (brackets).

The line should look like this:

docmd.applyfilter "filterName", "fieldName1='" & strVal & "'"

Also, you do realize that passing the second condition is going to be applied to the saved filter, further filtering the records.
If you don't want that you can just set the Filter property for the form:

me.filter = "fieldName1='" & strVal & "'"
me.filteron = true


0
 

Author Comment

by:ellenjbr
ID: 21751458
I will try your suggestions and get back with you this evening ... thank you!
0
 

Author Closing Comment

by:ellenjbr
ID: 31465639
Thank you!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now