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

Date Compare in Access db

Hi there
Can some one help me with this issue. I have 2 text fields which user selects the date from calender control. Now i want to retreive data from table which falls in the range of these 2 text fields
here is the code i have written. When i run this form it returns the resultset with no rows.(EMPTY resultset)
Expand|Select|Wrap|Line Numbers
  1. sdate = CDate(Forms![ResolvedIncidentsbySevierity]![Text3])
  2. edate = CDate(Forms![ResolvedIncidentsbySevierity]![Text5])
  3.  
  4. sql = "select IncidentsResolved.Severity,count(IncidentsResolved .Severity) from IncidentsResolved WHERE ((IncidentsResolved.[Arrival Time] >= " & sdate & ") AND (IncidentsResolved.[Arrival Time] <= " & edate & ")) GROUP BY IncidentsResolved.Severity"
  5.  
  6. Set MyDB = DBEngine.Workspaces(0).OpenDatabase("D:\Reports\db 1.mdb")
  7. Set MySet = MyDB.OpenRecordset(sql, DB_OPEN_DYNASET)
  8.  
  9. If (MySet.EOF = False And MySet.BOF = False) Then
  10. MySet.MoveFirst
  11. level1.Value = MySet.Fields(1)
  12. MySet.MoveNext
  13. level2.Value = MySet.Fields(1)
  14. MySet.MoveNext
  15. level3.Value = MySet.Fields(1)
  16. MySet.MoveNext
  17. ' level4.Value = MySet.Fields(1)
  18. Else
  19. MsgBox ("No data found")
  20. End If
  21.  
  22. MySet.Close
  23. Set MyDB = Nothing
I have also tried by replacing the above sql stmt to and still no luck
Expand|Select|Wrap|Line Numbers
  1. sql = "select IncidentsResolved.Severity,count(IncidentsResolved .Severity) from IncidentsResolved WHERE ((IncidentsResolved.[Arrival Time] >= #sdate#) AND (IncidentsResolved.[Arrival Time] <= #edate#)) GROUP BY IncidentsResolved.Severity"
Apr 7 '08 #1
2 1012
Try this:
Expand|Select|Wrap|Line Numbers
  1. sql = "select IncidentsResolved.Severity,count(IncidentsResolved .Severity) from IncidentsResolved WHERE ((IncidentsResolved.[Arrival Time] >= #" & sdate & "#) AND (IncidentsResolved.[Arrival Time] <= #" & edate & "#)) GROUP BY IncidentsResolved.Severity"
Apr 7 '08 #2
NeoPa
32,556 Expert Mod 16PB
Try :
Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT [Severity]," & _
  2.               "Count([Severity]) " & _
  3.       "FROM IncidentsResolved " & _
  4.       "WHERE [Arrival Time] Between #" & Format(Me.sdate,'m/d/yyyy') & "# " & _
  5.                                "And #" & Format(Me.edate,'m/d/yyyy') & "# " & _
  6.       "GROUP BY [Severity]"
PS. May I remind you that [ CODE ] tags are expected whenever posting code in these forums.

Welcome to Bytes :)
Apr 7 '08 #3

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

Similar topics

4
by: Christine | last post by:
I am having the strangest problem. I use the Date function in several of my forms and modules in an Access 2000 mdb. Lately, wherever in my code (in this one mdb) I use the Date function, it...
4
by: jty202 | last post by:
I have string that contains a date in this format (14-Jan-05). I want to store in date object if theres one and access each part of the date (month, year, dates, day of week). Specifically I...
9
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database...
1
by: Budd | last post by:
Hi everyone i got a problem on date, it is... 1, i get the date from calendar component 2, compare today and selected date is equal (compare method) 3 count the number of day between this...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
1
by: afr0ninja | last post by:
Hello all, and thank you in advance for your assistance. I'm pretty new to access and I'm trying to teach myself some VBA by using various bits of code I find here and there mixed with my own....
2
by: akshaycjoshi | last post by:
Hi, I am developing one application which requires me to compare date.The dataabse being MS access 2003. When i execute the query in c# it does not show any record ,the date although matches with...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
2
tuxalot
by: tuxalot | last post by:
I have a textbox, on with a record source . FrmMain is a tabbed form showing injury data for a given EmployeesID. I have a textbox, on a subform . with as the record source. is entered by a...
1
by: camastanta | last post by:
Hi How to compare a date/time via VBA with a date/time in an Access DB? The query I use adoRS.Open "SELECT * FROM currentpositions WHERE ((currentpositions. )=" & "#" &...
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
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:
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...
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.