By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

How to filter a repor with a textbox value on the report

P: 1
I have a report which is based on a querry i created in access. The report has a date field. on the report, I have two text boxes labled "FROM" and "TO" respectively. and the a button labled "FILTER".
I want the report to show only records which date field falls within the date value "FROM" textbox and the "TO" textbox
Aug 7 '12 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 2.5K+
P: 3,284
King JOT,

If I understand your question properly, the following code, initiated by clicking the Filter button should work:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  4. Private Sub cmdFilter_Click()
  5. On Error GoTo EH
  6.     Me.Filter = "Date >= #" & Me.txtFROM & _
  7.         "# AND Date <= #" & Me.txtTO & "#"
  8.     Me.FilterOn = True
  9.     Exit Sub
  10. EH:
  11.     MsgBox Err.Number & " " & Err.Description
  12. End Sub
Please let me know if this helps.
Aug 7 '12 #2

Expert Mod 5K+
P: 5,397
Why are you doing the filter in the report?
Create a form with the from and to dates in two text fields and a button to run the report.
You can use some VBA to validate the dates
Then use a parameter based query refering back to the form as the record source for your report.
When you open the report, the form will open, user enters the dates and the report runs...
I use the onclose event of the report to close the form.

Step by Step example is here:

Aug 9 '12 #3

Expert Mod 5K+
P: 5,397
Moderator's Note:
Do to a recent round of unrelated posts to this thread, any further posts to this thread need to be in direct address to King JOT original post or provide some additional helpful information such as a new feature, or one that was overlooked.

Other non-related posts will be removed and treated as spam/thread-hijack.

Oct 17 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.