473,387 Members | 1,528 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,387 software developers and data experts.

report by date

101 100+
Hi,
My project is in MS Access 2002.
In that I have one form which I am using to generate report by date.
In that form I have two three fields StartDate,EndDate,ItemNo all are of type Text.
Now when I select StartDate and EndDate both of same Year then its working properly.
But if I select StartDate from Previous Year and Today's Date as EndDate then it will simply show results of current year and only of StartDate.
Means if i enter StartDate=1/1/2007
and EndDate=02/19/2008
then it will show all results of current year(1/1/2008-02/19/2008) and results ,match date only 1/1/2007
but its not showing results between 1/1/2007 to 1/1/2008.

I am using this query
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM PRODUCTION
  3. WHERE ((PRODUCTION.ItemNo=Forms!Form1!ItemNo) And ((PRODUCTION.ODate) Between Forms!Form1!StartDate And Forms!Form1!EndDate));
I think my all fields are of type Text that's why this problem occur.
So I don't know what to do?
Thanks for Help.
Feb 19 '08 #1
12 1734
Scott Price
1,384 Expert 1GB
Have you tried changing the data types in each date field to the Date data type?

Regards,
Scott
Feb 19 '08 #2
billa856
101 100+
Have you tried changing the data types in each date field to the Date data type?

Regards,
Scott

No I don't know how to do that?
Is it like this
PARAMETERS [Forms]![Form1]![StartDate] DateTime, [Forms]![Form1]![EndDate] DateTime;
SELECT *
FROM PRODUCTION
WHERE (((PRODUCTION.ODate) Is Not Null And (PRODUCTION.ODate) Between [Forms]![Form1]![StartDate] And [Forms]![Form1]![EndDate]));

Or something else?
whenever i run this query it will show me that you cancled previous operation.
Feb 19 '08 #3
Scott Price
1,384 Expert 1GB
Open the table concerned in Design view. Click on the field that contains your date entries and you will see in the second column the data type. Change to Date/Time.

This will force valid Date/Time comparisons rather than what you have now, which is a String comparison.

Regards,
Scott
Feb 19 '08 #4
billa856
101 100+
Sorry but I can't change its type from text to DateTime bcz some of entries in Date field are blank.
I have to use the tables created by some other peoples working before me on this project.So for easy doing they use Text as type instead of DateTime and also its format of entering date is mm/dd/yy instead of longDate,mediumDate or shortDate.And now if I change it then I have to change the many forms and tables in entire project and it will take time more than a week bcz its not only one project but its two projects merge in one.So its not easy for me to do that.
Feb 19 '08 #5
Scott Price
1,384 Expert 1GB
As you are finding out, "for easy doing" is a very deceitful argument. In the moment it may seem easier, however, in the long run it ALWAYS turns out harder. Date/Time literals are made for exactly what you are trying to do, but if you choose to not use them, it is NOT 'for easy doing', sorry to break this to you.

VBA provides the CDate() function which can be used in vba code to create a Date/Time value from a String value. However, I don't think you can use it inside an Access query. You can try if you like.

Otherwise you will find that looking for the 'easy way out' will cost you more time, money and frustration than just doing it right in the first place.

Good luck!

Regards,
Scott
Feb 19 '08 #6
NeoPa
32,556 Expert Mod 16PB
Scott is absolutely right of course. We HIGHLY recommend you redesign your table for easier use.

However, to get you moving you can try the following.
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM PRODUCTION
  3. WHERE (([ItemNo]=Forms!Form1![ItemNo])
  4.   AND  (CDate([ODate]) Between Forms!Form1!StartDate AND Forms!Form1!EndDate))
PS It clearly doesn't take too much imagination to see why a string comparison on dates formatted as m/d/y would make a pig's ear of the whole process ;)
Feb 20 '08 #7
billa856
101 100+
I didn't create or use that thing for my sake of easy doing, but programmer working before me who created the database, did that for his convinience and now I have to use it.But I think now I have to change all things on my own.When I started on project ,at that time I have doubt that it will create problems in future and now its becoming true.It will take time to change all things but I have to do it otherwise it will create more problems afterwards.

And ya ur CDate() function is not working in Query.

By the way thanks for ur help.
Feb 20 '08 #8
NeoPa
32,556 Expert Mod 16PB
...
And ya ur CDate() function is not working in Query.

By the way thanks for ur help.
That's interesting. I tested it in mine & it worked fine.
When you say it didn't work, what did you mean exactly?
Are you sure it was the CDate() part that wasn't working?

And lastly, you're very welcome. I hope I can help you get past this little problem to allow you to focus on updating your database without the added pressure of producing this query still being required.
Feb 20 '08 #9
billa856
101 100+
That's interesting. I tested it in mine & it worked fine.
When you say it didn't work, what did you mean exactly?
Are you sure it was the CDate() part that wasn't working?

And lastly, you're very welcome. I hope I can help you get past this little problem to allow you to focus on updating your database without the added pressure of producing this query still being required.

Ya whenever I used CDate() then it will show nothing.But if I remove it then it will show results but with the same problems I mentioned before.But now I am updating the database.
Thanks for ur help.
Feb 21 '08 #10
NeoPa
32,556 Expert Mod 16PB
It's good that you're going the redesign route.

However, not having CDate() available is something I'd regard as worrying. Would you be able to do a quick test in the VBA immediate window (Alt-F11 from Access + Ctrl-G) :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print CDate("1 Dec 2008")
I'd be interested to see what's displayed.

Also, check in the VBA window what references are linked in your project. Select Tools / References to see the currently selected list.
Feb 21 '08 #11
billa856
101 100+
It's good that you're going the redesign route.

However, not having CDate() available is something I'd regard as worrying. Would you be able to do a quick test in the VBA immediate window (Alt-F11 from Access + Ctrl-G) :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print CDate("1 Dec 2008")
I'd be interested to see what's displayed.

Also, check in the VBA window what references are linked in your project. Select Tools / References to see the currently selected list.

its showing no results.
By the way, Date format is also different as I mentioned in previous posts..Its not one of the ShortDate(mm/dd/yyyy),MediumDate(mm/ddd/yy) or LongDate(Sunday,june 19,1994).its mm/dd/yy.

And Ya list of references are listed below.
->Visual Basic For Application.
->Microsoft Access 10.0 Object Library.
->OLE Automation
->Microsoft Active X Data Objects 2.1 Library
->Microsoft Windows Common Controls-2.6.0(SP3)
->Microsoft Calender Control 10.0
Feb 21 '08 #12
Scott Price
1,384 Expert 1GB
This is indeed strange... btw you can also use the shorter syntax in the immediate window:
Expand|Select|Wrap|Line Numbers
  1. ?CDate("12/23/02")
(it's easier to type :-)

The mm/dd/yy format is not the problem here as it is a valid date format that Access will recognize and convert to a date.

I would suggest two things:

A. If this test doesn't work in a brand new, clean database, you probably will need a re-install.

B. If it does work, you likely have some kind of corruption in your existing database.

Regards,
Scott
Feb 21 '08 #13

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

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
0
by: Rahul Chatterjee | last post by:
Hello All I have designed a dotnet application using VB which basically takes a selection and passes value to a crystal report which in turn passes the value to a Stored procedure. After the...
2
by: Arnold | last post by:
Greetings Gurus, In a report showing the names of students and their progress, I am getting an error in the name field (Name: #Error). The report gets its data from an unbound form containing...
5
by: sara | last post by:
I have reports that run from a form where the user can choose a date range, or they run automatically for a week in the "Weekly Reports" option. I created 2 queries and 2 reports - one query...
1
Altius
by: Altius | last post by:
Access Version: 2003 OS: XP Pro Sorry if this is a bit long winded. First a little info about the database. This database is used to keep track of checkout information from our production...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
4
by: RachH | last post by:
Is there a way to pass a value to a report via VBA so the value can then be displayed in the report as a concantenation with a string? I have a report that displays all pricings that have occured...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.