473,549 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pulling the Record Number into a Query - Attempt 2

I have a table of dates in ascending order but with varying intervals. I
would like to create a query to pull out the date (in field 1) and then pull the date from the subsequent record (and store it in field 2).

I would like to run a query that returns all the data in the table plus the record number, in a similar sense to the getuser() command to get the User's Identity, I would like a GetRecord() command.

Is this possible, or can someone think of a better way of doing this?
Thanks, John

Also Posted to:
------------------
microsoft.publi c.access
comp.databases. ms-access


Nov 12 '05 #1
3 14115
SA
John:

Possibly the reason that you received no replies on Attempt 1, is that you
post is pretty unclear. There appear to be two parts to your question; if
I've missed something then you're back to attempt three.

1.) You want to create a query that contains a field that pulls a date and
then in a created field within the query, pulls the next ascending date into
each row in the query. Not hard, you simply have to use a subquery within
your query. I'll assume that the date field is the primary key for table
in question (so that the dates are all unique.)

Here's sample SQL:

SELECT YourTable.YourD ateField, (Select First(YourDateF ield) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourD ateField

What this query does, is use a subquery (which is required to include a
primary key comparison with the target table,) in its second field (the same
table is used but is aliased so that Access compares your table to a
separate unique rowset) to return the first date greater than the date
displayed in the first field (i.e. YourDateField); the second field is
aliased as "NextDate"

2.) Related to the second part of your post, i.e. "I would like to run a
query that returns all the data in the table plus the record number ......
This makes no sense. Access doesn't store absolute record numbers (unless
you have an auto number field, in which case simply add that field), because
they have no meaning over time, (i.e as records may be deleted from earlier
records.) If what you are talking about adding some type of row number to
the returned query simply to display a row number, then again, all you need
is a subquery to do that. (See our web under Code and Design Tips; Queries
area, to see how to create an numbered return for each row in your query.)
How that releates to GetUser() is totally unclear.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
"John Ortt" <Jo******@STOPS PAMMINGMEbaesys tems.com> wrote in message
news:3f******** @baen1673807.gr eenlnk.net...
I have a table of dates in ascending order but with varying intervals. I would like to create a query to pull out the date (in field 1) and then

pull
the date from the subsequent record (and store it in field 2).

I would like to run a query that returns all the data in the table plus

the
record number, in a similar sense to the getuser() command to get the

User's
Identity, I would like a GetRecord() command.

Is this possible, or can someone think of a better way of doing this?
Thanks, John

Also Posted to:
------------------
microsoft.publi c.access
comp.databases. ms-access


Nov 12 '05 #2
SA
John:

Possibly the reason that you received no replies on Attempt 1, is that you
post is pretty unclear. There appear to be two parts to your question; if
I've missed something then you're back to attempt three.

1.) You want to create a query that contains a field that pulls a date and
then in a created field within the query, pulls the next ascending date into
each row in the query. Not hard, you simply have to use a subquery within
your query. I'll assume that the date field is the primary key for table
in question (so that the dates are all unique.)

Here's sample SQL:

SELECT YourTable.YourD ateField, (Select First(YourDateF ield) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourD ateField

What this query does, is use a subquery (which is required to include a
primary key comparison with the target table,) in its second field (the same
table is used but is aliased so that Access compares your table to a
separate unique rowset) to return the first date greater than the date
displayed in the first field (i.e. YourDateField); the second field is
aliased as "NextDate"

2.) Related to the second part of your post, i.e. "I would like to run a
query that returns all the data in the table plus the record number ......
This makes no sense. Access doesn't store absolute record numbers (unless
you have an auto number field, in which case simply add that field), because
they have no meaning over time, (i.e as records may be deleted from earlier
records.) If what you are talking about adding some type of row number to
the returned query simply to display a row number, then again, all you need
is a subquery to do that. (See our web under Code and Design Tips; Queries
area, to see how to create an numbered return for each row in your query.)
How that releates to GetUser() is totally unclear.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

"John Ortt" <Jo******@STOPS PAMMINGMEbaesys tems.com> wrote in message
news:3f******** @baen1673807.gr eenlnk.net...
I have a table of dates in ascending order but with varying intervals. I would like to create a query to pull out the date (in field 1) and then

pull
the date from the subsequent record (and store it in field 2).

I would like to run a query that returns all the data in the table plus

the
record number, in a similar sense to the getuser() command to get the

User's
Identity, I would like a GetRecord() command.

Is this possible, or can someone think of a better way of doing this?
Thanks, John

Also Posted to:
------------------
microsoft.publi c.access
comp.databases. ms-access


Nov 12 '05 #3
Thanks for the post SA. You have answered my question.

Essentially I just wanted the Date and the subsequent Date on the same line
with as few queries as possible.

My reference to the GetUser() Command was just an example of how I envisaged
a GetRecord() command working.

I was originally going to use the record number minus 1 in a separate table
to link each record with the record which followed it. The way you have
used is far more efficient.

I apologise for the two posts, I attempted to cancel the first post after
somebody in work pointed out that we are not supposed to crosspost to
internal & external newsgroups.

My Cancel request seems to have failed.......

Thanks Again,

John
"SA" <~f***********@ nspm.com> wrote in message
news:bp******** *@ngspool-d02.news.aol.co m...
John:

Possibly the reason that you received no replies on Attempt 1, is that you
post is pretty unclear. There appear to be two parts to your question; if
I've missed something then you're back to attempt three.

1.) You want to create a query that contains a field that pulls a date and
then in a created field within the query, pulls the next ascending date into each row in the query. Not hard, you simply have to use a subquery within your query. I'll assume that the date field is the primary key for table
in question (so that the dates are all unique.)

Here's sample SQL:

SELECT YourTable.YourD ateField, (Select First(YourDateF ield) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourD ateField

What this query does, is use a subquery (which is required to include a
primary key comparison with the target table,) in its second field (the same table is used but is aliased so that Access compares your table to a
separate unique rowset) to return the first date greater than the date
displayed in the first field (i.e. YourDateField); the second field is
aliased as "NextDate"

2.) Related to the second part of your post, i.e. "I would like to run a
query that returns all the data in the table plus the record number ......
This makes no sense. Access doesn't store absolute record numbers (unless you have an auto number field, in which case simply add that field), because they have no meaning over time, (i.e as records may be deleted from earlier records.) If what you are talking about adding some type of row number to the returned query simply to display a row number, then again, all you need is a subquery to do that. (See our web under Code and Design Tips; Queries area, to see how to create an numbered return for each row in your query.)
How that releates to GetUser() is totally unclear.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
"John Ortt" <Jo******@STOPS PAMMINGMEbaesys tems.com> wrote in message
news:3f******** @baen1673807.gr eenlnk.net...
I have a table of dates in ascending order but with varying intervals. I would like to create a query to pull out the date (in field 1) and
then pull
the date from the subsequent record (and store it in field 2).

I would like to run a query that returns all the data in the table
plus the
record number, in a similar sense to the getuser() command to get the

User's
Identity, I would like a GetRecord() command.

Is this possible, or can someone think of a better way of doing this?
Thanks, John

Also Posted to:
------------------
microsoft.publi c.access
comp.databases. ms-access



Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4731
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record onto the bottom of the list (even though it keeps its record number). Also, There are certin names that i click on the list, and it will not...
1
3000
by: Skully Matjas | last post by:
Thank you for getting back to me. I am very new at this so i didnot understand what you said, here i will give as much cetails as possible: 1) The combo box i am using is combox39 2) I imported a a table of parents of a school (it has name,address,#, etc...) 3) I nead to input a ID Number (ralphs card) for some of the parents 4) The ID...
1
1653
by: John Ortt | last post by:
I have a table of dates in ascending order but with varying intervals. I would like to create a query to pull out the date (in field 1) and then pull the date from the subsequent record (and store it in field 2). I would like to run a query that returns all the data in the table plus the record number, in a similar sense to the getuser()...
4
4040
by: amywolfie | last post by:
I've been trying to do something for about 3 days – I get close, but not 100%. I am trying to: Open frmRevisionHistory from a button on frmFeeInput. If there is NO RELATED RECORD, then I need to create one in frmRevisionHistory, and pass the PK (PK_Fees) on frmFeeInput to FK_Fees on the 2nd form.
3
15411
by: Mihaly | last post by:
I want to update a record into a table in SQL Server 2000 database from C#. This table is used concurently for other users too, and I want to be sure that from the read of record to the update no other user was updated the record. Please tell me how can I do this. Thank you!
12
5562
by: magmike | last post by:
Accidentally deleted a record. Anyway to get it back? If not, I know the ID number - which is an autonumber field. Because of the related data from other tables, would I be able to create a new record and make its ID number, that of the deleted record? Thanks! magmike
0
2031
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in house case number, appt date and time) for the applicants yearly history and the childs yearly history and then print a report with the applicants...
12
2358
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A registry mark given by underwriters (as at Lloyd's) to ships in first-class condition. Inferior grades are indicated by A 2 and A 3. () The first...
1
4587
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in Database but I'm stuck in the EDIT. I'm getting 2 problems over here. Below is the description: 1)The FIRST page will list all the records from the...
0
7480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7751
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7992
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6088
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5396
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5119
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1973
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.