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. - >=[forms]![frmCompletedOrdersMenuDateRange]![txtDateFrom] And <=[forms]![frmCompletedOrdersMenuDateRange]![txtDateTo]
And below is my VBA Code in the form -
Option Compare Database
-
-
Private Sub cmdtoday_Click()
-
'Sets the Date From and Date To text boxes
-
'to Today's Date
-
-
Me!txtDateFrom = Date
-
Me!txtDateTo = Date
-
-
End Sub
-
-
Private Sub cmdweek_Click()
-
'Sets the Date From and Date To text boxes
-
'to show complete working week (Mon - Fri)
-
-
Dim today
-
-
today = Weekday(Date)
-
-
Me!txtDateFrom = DateAdd("d", today - 7, Date)
-
Me!txtDateTo = DateAdd("d", (today * -1) + 1, Date)
-
-
End Sub
-
-
Private Sub cmdmonth_Click()
-
'Sets the Date From and Date To text boxes
-
'to show complete month (from start to end of current month)
-
-
Me!txtDateFrom = CDate("01/" & Month(Date) & "/" & Year(Date))
-
Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtDateFrom))
-
-
End Sub
-
-
Private Sub cmdyear_Click()
-
'Sets the Date From and Date To text boxes
-
'to show complete current year
-
-
Me!txtDateFrom = CDate("01/01/" & Year(Date))
-
Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtDateFrom))
-
-
End Sub
-
-
Private Sub cmdReport_Click()
-
On Error GoTo Err_cmdReport_Click
-
-
Dim stDocName As String
-
-
stDocName = "rptCompletedOrdersDateRange"
-
-
'Check values are entered into Date From and Date To text boxes
-
'if so run report or cancel request
-
-
If Len(Me.txtDateFrom & vbNullString) = 0 Or _
-
Len(Me.txtDateTo & vbNullString) = 0 Then
-
MsgBox "Please ensure that a report date range " & _
-
"is entered into the form", _
-
vbInformation, "Required Data..."
-
Exit Sub
-
Else
-
DoCmd.OpenReport stDocName, acViewReport
-
End If
-
Exit_cmdReport_Click:
-
Exit Sub
-
-
Err_cmdReport_Click:
-
MsgBox Err.Description
-
Resume Exit_cmdReport_Click
-
-
End Sub
-
I can't figure it out for the life of me, but I know it's probably simple. Can anyone help out?
Answered my own question I inputted a criteria into the query for each seperate field. -
Like IIf(IsNull([forms]![frmCompletedOrdersMenuDateRange]![txtRequestor]),"*",[forms]![frmCompletedOrdersMenuDateRange]![txtRequestor])
-
1 1311
Answered my own question I inputted a criteria into the query for each seperate field. -
Like IIf(IsNull([forms]![frmCompletedOrdersMenuDateRange]![txtRequestor]),"*",[forms]![frmCompletedOrdersMenuDateRange]![txtRequestor])
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
| |