Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Filter syntax issue

Posted on 2013-06-08
2
Medium Priority
?
416 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

886 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