?
Solved

Filter syntax issue

Posted on 2013-06-08
2
Medium Priority
?
413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 39231770
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
ID: 39231776
Thank you.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

719 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