Solved

Filter syntax issue

Posted on 2013-06-08
2
404 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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