Solved

Applyfilter using string variable

Posted on 2008-06-10
4
280 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 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

12 Experts available now in Live!

Get 1:1 Help Now