473,408 Members | 2,477 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,408 software developers and data experts.

Date Calculation (Time Frame) in Query

132 100+
I have several reports that are date driven. (There is a Date field called date received in the DB) I need to offer the user a time frame for each report. For example, I have a report named by employee. I want to offer the user the opportunity to run the report from say 12/31/07 - 1/31/08. Can I do something like this in the date received field of the query?

>=[Enter FROM Date]; <=[Enter TO Date].

Also, How can I create a mask so the user has to enter the date MM/DD/YYYY?
Jan 23 '08 #1
8 4015
MindBender77
234 100+
I have several reports that are date driven. (There is a Date field called date received in the DB) I need to offer the user a time frame for each report. For example, I have a report named by employee. I want to offer the user the opportunity to run the report from say 12/31/07 - 1/31/08. Can I do something like this in the date received field of the query?

>=[Enter FROM Date]; <=[Enter TO Date].

Also, How can I create a mask so the user has to enter the date MM/DD/YYYY?
The easiest way might be to have a small form ie. popup or modal with 2 text boxes. Make one DateFrom and the other DateTo. On the OnExit event of the DateTo textbox run the report. Using code like this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport ("YourReport", acpreview)
  2.  
In the query that produces the report, under the criteria for Date:
This makes the input from the Form the criteria in the query.
>=Forms![FormName1]![DateFrom] and <=Forms![FormName1![DateTo]

Or
between Forms![FormName1]![DateFrom] and Forms![FormName1![DateTo]

As for the input mask try: In the properties of the textbox, under the data tab
99/99/9999;0;_

Hope This Helps,
JS
Jan 24 '08 #2
Proaccesspro
132 100+
The easiest way might be to have a small form ie. popup or modal with 2 text boxes. Make one DateFrom and the other DateTo. On the OnExit event of the DateTo textbox run the report. Using code like this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport ("YourReport", acpreview)
  2.  
In the query that produces the report, under the criteria for Date:
This makes the input from the Form the criteria in the query.
>=Forms![FormName1]![DateFrom] and <=Forms![FormName1![DateTo]

Or
between Forms![FormName1]![DateFrom] and Forms![FormName1![DateTo]

As for the input mask try: In the properties of the textbox, under the data tab
99/99/9999;0;_

Hope This Helps,
JS

JS,

One hang-up. I have a window that allows the user to select a report from a list. How will I know which reoprt the user selected when this code is executed?

DoCmd.OpenReport ("YourReport", acpreview)

I'm guessing I would have to implement some kind of Case statement?
Jan 24 '08 #3
jaxjagfan
254 Expert 100+
I have several reports that are date driven. (There is a Date field called date received in the DB) I need to offer the user a time frame for each report. For example, I have a report named by employee. I want to offer the user the opportunity to run the report from say 12/31/07 - 1/31/08. Can I do something like this in the date received field of the query?

>=[Enter FROM Date]; <=[Enter TO Date].

Also, How can I create a mask so the user has to enter the date MM/DD/YYYY?
I have a form that a user enters a start date and an end date into 2 text boxes on the form. There is a button to open the report.
There is a query that drives the report.
In the Criteria of the my date field I have this:

Between [Forms]![frmReports]![txtStart] And [Forms]![frmReports]![txtEnd]

My process is actually far more involved with reports being chosen from a listbox, dates being entered, and possible values to filter the reports picked from a multiselect list .... but let's keep it simple to begin with.
Jan 24 '08 #4
Proaccesspro
132 100+
I have a form that a user enters a start date and an end date into 2 text boxes on the form. There is a button to open the report.
There is a query that drives the report.
In the Criteria of the my date field I have this:

Between [Forms]![frmReports]![txtStart] And [Forms]![frmReports]![txtEnd]

My process is actually far more involved with reports being chosen from a listbox, dates being entered, and possible values to filter the reports picked from a multiselect list .... but let's keep it simple to begin with.

Mine sounds similar....I have a list of reports available to the user...once they select a report they would click on the Print Report button. A pop-up window then appears asking them to input a date range...once input, the report is sent to the printer. My problem is, how do I know which report was selected by the user?
Jan 24 '08 #5
MindBender77
234 100+
Mine sounds similar....I have a list of reports available to the user...once they select a report they would click on the Print Report button. A pop-up window then appears asking them to input a date range...once input, the report is sent to the printer. My problem is, how do I know which report was selected by the user?
In theory, you could make a print report button for each report; make them all invisible until the user selects a report. After a selection is made, only that print button is visible.

Expand|Select|Wrap|Line Numbers
  1. if Listbox1.selected = "Report1" then
  2. Button1.visible=true
  3. button2.visible = false
  4. etc. etc.
  5. end if
  6.  
Jan 24 '08 #6
Proaccesspro
132 100+
In theory, you could make a print report button for each report; make them all invisible until the user selects a report. After a selection is made, only that print button is visible.

Expand|Select|Wrap|Line Numbers
  1. if Listbox1.selected = "Report1" then
  2. Button1.visible=true
  3. button2.visible = false
  4. etc. etc.
  5. end if
  6.  
I tried to implement but getting an error. Here is my code:

If ReportList.ItemSelected = "By Age (Open Appelas)" Then
PrintBtn1.Visible = True
PrintBtn1.Visible = flase
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
End If

I have this code in a listbox named reportlist. I have it under the ON CLICK section. It stops at item selected and says "method or data member not found"
Jan 24 '08 #7
jaxjagfan
254 Expert 100+
I tried to implement but getting an error. Here is my code:

If ReportList.ItemSelected = "By Age (Open Appelas)" Then
PrintBtn1.Visible = True
PrintBtn1.Visible = flase
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
PrintBtn1.Visible = False
End If

I have this code in a listbox named reportlist. I have it under the ON CLICK section. It stops at item selected and says "method or data member not found"
[code]
If Me.lstChannelReport.ItemsSelected.Count = 0 Then
MsgBox "No Report Selected!
Me.lstChannelReport.SetFocus
Else
DoCmd.OpenReport Me.lstChannelReport.Column(0), acViewPreview
End If
{/CODE]

lstChannelReport is a listbox with 3 columns. The 1st column contains the Access name for the report and its width is set to 0, 2nd column is a Descriptive Name the user picks from ("Quarterly Sales Report" where the actual report is named rptQtrSales). The 3rd column (width is set to 0) is a report description. Its value displays in an unbound textbox after the user selects a report.

You can attach this code to a single cmdbutton - no need to do all the hide/show.

I have the 2 date textboxes for user to enter dates.

I saw a commercial app with a similar layout and made my own version in Access. I'm including a screenshot of the layout - maybe it will give you some ideas.
Attached Images
File Type: jpg e2e.jpg (20.2 KB, 287 views)
Jan 25 '08 #8
Proaccesspro
132 100+
[code]
If Me.lstChannelReport.ItemsSelected.Count = 0 Then
MsgBox "No Report Selected!
Me.lstChannelReport.SetFocus
Else
DoCmd.OpenReport Me.lstChannelReport.Column(0), acViewPreview
End If
{/CODE]

lstChannelReport is a listbox with 3 columns. The 1st column contains the Access name for the report and its width is set to 0, 2nd column is a Descriptive Name the user picks from ("Quarterly Sales Report" where the actual report is named rptQtrSales). The 3rd column (width is set to 0) is a report description. Its value displays in an unbound textbox after the user selects a report.

You can attach this code to a single cmdbutton - no need to do all the hide/show.

I have the 2 date textboxes for user to enter dates.

I saw a commercial app with a similar layout and made my own version in Access. I'm including a screenshot of the layout - maybe it will give you some ideas.

It all works GREAT, except I am having a little difficulty with the form I created to capture the date range.

I have the code in the AFTER UPDATE section. I have the properties set to POPUP and MODAL. Once something is entered in both boxes, nothing happens unless I press the tab key or click somewhere else on the screen. Can I make it so that once both fields aer populated, the program continues automatically? Also, the form does not disappear automatically once the data is captured, I have to close it manually.
Jan 30 '08 #9

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

Similar topics

1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
2
by: Norbert Lieckfeldt | last post by:
I am setting up a database for a friend who's an Optician, using MS Access 2002. All seems to be working well, but I have hit a snag. There's a calculated field both in a form and a query which...
1
by: John Feeley | last post by:
am tring to add a number of years to a dob. im doing this by adding my date+years*365.26 I get a string of numbers. I then convert the number in the next column to actual date again. I'm getting...
2
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result....
4
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also...
4
by: steve | last post by:
Hi, First my apologies for double-posting but I am not sure wether this is a VB.Net or TSQL problem. I have the following problem: I generate a T-SQL string in order to fill my Dataset and...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
1
by: c8tz | last post by:
This is a query I have created that picks up the top 3 dates for this data (for example) : Tree Pos2 Date 1 15 23/08/2005 1 20 12/02/2006 1 32 15/10/2006 ...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.