Solved

Filter syntax issue

Posted on 2013-06-08
2
363 Views
Last Modified: 2013-06-08
On a form I have a click event with this code:

    Me.Filter = "[Sale Price] = " & Chr(34) & Me.txtSalePrice & Chr(34)
    Me.FilterOn = True

But I get a data type mismatch error.  The field is a Currence formatted field so I'm sure the syntax of my code is wrong.  It works fine if the field is a text field.

Then,

I have the same issue with a date field... here's my code for that but I get a data type mismatch error there too...

    Me.Filter = "[Sale Date] = " & Chr(34) & Me.txtSaleDate & Chr(34)
    Me.FilterOn = True

???
0
Comment
Question by:SteveL13
2 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
Comment Utility
You don't want the Chr(34), which is the quote character and used to delimit strings.  Since this is a date, you want:

Me.Filter = "[Sale Date] = #" & Format(Me.txtSaleDate,"mm/dd/yyyy") & "#"

 a numeric number would be:

Me.Filter = "[Sale Amount] = " & Me.txtSaleAmount

Jim.
0
 

Author Closing Comment

by:SteveL13
Comment Utility
Thank you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

772 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

10 Experts available now in Live!

Get 1:1 Help Now