473,396 Members | 1,756 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.

how to select records from a table where date and time are last -Ms Access 2007

I created a table called "tblfeesdetails" with fields; "groupid", "Academic_year", "Term", "Insect_date and time" and these fields are updated base on a command button click and the update date and time recorded in the field "Insect_date and time". The records in table "tblfeesdetails" has date 1, date 2,... and date 9 base on the update from the command button. Now, I want select all from the table "tblfeesdetails" where Insect_date and time = 9 or has the last date and time

This is the code i used
Expand|Select|Wrap|Line Numbers
  1.  strsqldetails = "Select * from tblfeesdetails where groupid = """ & mgroupid & """; "
Mar 14 '11 #1
4 2425
NeoPa
32,556 Expert Mod 16PB
This makes little sense when you say you want to specify the results either match a specific Group ID or match the last Date/Time found. Do you mean both must match (The record with the last Date/Time for the specified group)?
Mar 15 '11 #2
I mean both must match (The record with the last Date/Time for the specified group)

System Error = type mismatch

Expand|Select|Wrap|Line Numbers
  1. strsqldetails = "Select * from tblfeesdetails where groupid = """ & mgroupid & """; "
Mar 15 '11 #3
NeoPa
32,556 Expert Mod 16PB
Try this instead then :
Expand|Select|Wrap|Line Numbers
  1. strSQLDetails = "SELECT tFD.* " & _
  2.                 "FROM   [tblFeesDetails] AS tFD" & _
  3.                 "       INNER JOIN" & _
  4.                 "      (SELECT LAST([Insect_Date and Time]) AS [LastDT]" & _
  5.                 "       FROM   [tblFeesDetails]" & _
  6.                 "       WHERE  ([GroupID] = '%G'")) AS sQ" & _
  7.                 "  ON   tFD.[Insect_Date and Time] = sQ.LastDT " & _
  8.                 "WHERE  (tFD.GroupID = '%G'")
  9. strSQLDetails = Replace(strSQLDetails, "%G", mGroupID)
This uses an embedded subquery that has the same filtering for the Group ID.
Mar 16 '11 #4
NeoPa
32,556 Expert Mod 16PB
Actually, that's the basic SQL sorted out, but it seems you may be dealing with a [GroupID] that isn't a text string (from the reported error message in your latest post - information that should also have been in the original question). In that case you need to remove the single quotes (') from the code. Single quotes indicate that the value between them should be treated as a text literal.
Mar 16 '11 #5

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

Similar topics

2
by: mcmcalex | last post by:
is there an easy way to make a date/time field (in Access) convert to a date field (in Excel) when using ms-query? I'm pretty good with xl, but new to access, so apologies if this is covered on p1...
2
by: Rolf | last post by:
Hi all, I Have a web page wich displays some data from an access DB using the Datalist control. I have 1 problem with a field of the type Data/Time. When I display the field using <%#...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
5
by: amanda27 | last post by:
I have a database that we use in our department for the status of our projects. In the form when you pick a project from the dropdown list I have a subform that pulls the data entered for the...
5
by: TIJK | last post by:
I'm attempting to create a database that stores details for my college project. But I'm currently in a rut at the moment. I want to be able to store the exact date and time when an order is made,...
3
by: mtgriffiths86 | last post by:
I have created a query using Microsoft access that will work out the difference between a time that i enter into the database (HH:MM:SS) and then to take away the current time. I have this working...
1
by: BulbFresh | last post by:
Hi, Quick one for you, i'm importing a file which has a long date and time format, so once imported i update each date field with the correct format (dd/mm/yyyy). I wrote this in on click of a...
3
by: kate2272 | last post by:
Hi Guys, Thanks heaps for assisting with my last question. I would like to automatically update a new record with date / time but I was wondering if it is possible for it not to live update...
1
by: neelsfer | last post by:
I have a cycling timing application. With lapracing the riders rides around a short track and in the program i enter the rider's race_number, each time they pass the finish line. I press enter and...
3
by: neelsfer | last post by:
i want to limit the capturing in a subform to the first 10 records. Pls help mainform = racesetupf (table name =racesetup) fields = racesetupid(autono) racename(txt); racedate(short) Subform...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.