472,373 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

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.public.access
comp.databases.ms-access


Nov 12 '05 #1
3 14001
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.YourDateField, (Select First(YourDateField) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourDateField

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******@STOPSPAMMINGMEbaesystems.com> wrote in message
news:3f********@baen1673807.greenlnk.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.public.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.YourDateField, (Select First(YourDateField) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourDateField

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******@STOPSPAMMINGMEbaesystems.com> wrote in message
news:3f********@baen1673807.greenlnk.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.public.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.com...
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.YourDateField, (Select First(YourDateField) _
as NextDate from YourTable as [Temp] WHERE _
[Temp].[YourDateField] > [YourTable].[YourDateField]) _
AS NextDate FROM YourTable _
ORDER BY YourTable.YourDateField

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******@STOPSPAMMINGMEbaesystems.com> wrote in message
news:3f********@baen1673807.greenlnk.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.public.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
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...
1
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...
1
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...
4
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...
3
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...
12
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...
0
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...
12
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...
1
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.