473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text Input Filter Criteria for Report

I have a form that generates a report based on a date range input, but I also want to add multiple "OPTIONAL" text fields to where if a user inputs a text into this field it will filter the report data by the filter and date range. And to also display an error if the text inputted does not exist in query. Here is what I have so far. I have a query and one of the fields in that query is named "Date Received" which has the following criteria.


Expand|Select|Wrap|Line Numbers
  1. >=[forms]![frmCompletedOrdersMenuDateRange]![txtDateFrom] And <=[forms]![frmCompletedOrdersMenuDateRange]![txtDateTo]
And below is my VBA Code in the form

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmdtoday_Click()
  4. 'Sets the Date From and Date To text boxes
  5. 'to Today's Date
  6.  
  7.     Me!txtDateFrom = Date
  8.     Me!txtDateTo = Date
  9.  
  10. End Sub
  11.  
  12. Private Sub cmdweek_Click()
  13. 'Sets the Date From and Date To text boxes
  14. 'to show complete working week (Mon - Fri)
  15.  
  16.     Dim today
  17.  
  18.     today = Weekday(Date)
  19.  
  20.     Me!txtDateFrom = DateAdd("d", today - 7, Date)
  21.     Me!txtDateTo = DateAdd("d", (today * -1) + 1, Date)
  22.  
  23. End Sub
  24.  
  25. Private Sub cmdmonth_Click()
  26. 'Sets the Date From and Date To text boxes
  27. 'to show complete month (from start to end of current month)
  28.  
  29.     Me!txtDateFrom = CDate("01/" & Month(Date) & "/" & Year(Date))
  30.     Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtDateFrom))
  31.  
  32. End Sub
  33.  
  34. Private Sub cmdyear_Click()
  35. 'Sets the Date From and Date To text boxes
  36. 'to show complete current year
  37.  
  38.     Me!txtDateFrom = CDate("01/01/" & Year(Date))
  39.     Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtDateFrom))
  40.  
  41. End Sub
  42.  
  43. Private Sub cmdReport_Click()
  44.     On Error GoTo Err_cmdReport_Click
  45.  
  46.     Dim stDocName As String
  47.  
  48.     stDocName = "rptCompletedOrdersDateRange"
  49.  
  50.     'Check values are entered into Date From and Date To text boxes
  51.     'if so run report or cancel request
  52.  
  53.     If Len(Me.txtDateFrom & vbNullString) = 0 Or _
  54.        Len(Me.txtDateTo & vbNullString) = 0 Then
  55.         MsgBox "Please ensure that a report date range " & _
  56.                "is entered into the form", _
  57.                vbInformation, "Required Data..."
  58.         Exit Sub
  59.     Else
  60.         DoCmd.OpenReport stDocName, acViewReport
  61.     End If
  62. Exit_cmdReport_Click:
  63.     Exit Sub
  64.  
  65. Err_cmdReport_Click:
  66.     MsgBox Err.Description
  67.     Resume Exit_cmdReport_Click
  68.  
  69. End Sub
  70.  
I can't figure it out for the life of me, but I know it's probably simple. Can anyone help out?
Mar 5 '17 #1

✓ answered by astroshark

Answered my own question I inputted a criteria into the query for each seperate field.
Expand|Select|Wrap|Line Numbers
  1. Like IIf(IsNull([forms]![frmCompletedOrdersMenuDateRange]![txtRequestor]),"*",[forms]![frmCompletedOrdersMenuDateRange]![txtRequestor])
  2.  

1 1311
Answered my own question I inputted a criteria into the query for each seperate field.
Expand|Select|Wrap|Line Numbers
  1. Like IIf(IsNull([forms]![frmCompletedOrdersMenuDateRange]![txtRequestor]),"*",[forms]![frmCompletedOrdersMenuDateRange]![txtRequestor])
  2.  
Mar 5 '17 #2

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

Similar topics

4
by: Chris Geihsler | last post by:
I have a set of udf's dealing that return a one column table of values parsed from a comma delimeted string. For example: CREATE FUNCTION . ( @patient_list varchar(2000) ) RETURNS...
2
by: Xiphias | last post by:
Hi, Im trying to change the color of a text box on a report that im printing from a form. On the form I got a check box that has to tricker the color of that textbox on the printed report....
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
1
by: Oliver Spiesshofer | last post by:
Hi, I have been searching for a good input filter class or how-to guide. All I found were vague concept descriptions or alpha-release or more than a year old, dead projects. Isn't there a...
2
by: tjdoss | last post by:
I am trying to display the "Filter by Form" criteria in a Report (that displays the filtered information). I have an unbound textbox with !. as the control source that will give me the Filter itself...
4
by: Fran | last post by:
I recently tried to use code for "Use a multi-select list box to filter a report" from Allen Browne in my database. I was able to add the code and adapt it to my needs, however I am getting an...
2
jmoudy77
by: jmoudy77 | last post by:
Hi, I've got a form with a cmdbttn that prints a report. The query for the report has a criteria based on a combo box on this form. When I press the cmdbttn to print the report, I get a popup...
3
by: Gord | last post by:
I'm trying to filter a report with a date in VB code. If I type an actual date bracketed with the pound symbol (i.e. #3-Jul-08#) I can get the filter to work. I can't seem to get it to work by...
1
by: axkoam | last post by:
Microsoft Access 2007. Background: I have a query that received work orders from out client system and runs them through access. Once in Access, an employee goes through the query output and...
9
LeighW
by: LeighW | last post by:
Hi all, I'd like a cover page that shows which filter criteria have been used when creating the report. If this can't be done/ is very hard to implement then I'll leave it be but I thought it...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.