
01-Nov-2005, 13:40 PM
|  | Guest | | | | | | | | | | Re: get most recent inserted record Do you insert Record by code or through the Form process?
Explain the process you use to insert Record and post code if appropriate.
--
HTH
Van T. Dinh
MVP (Access)
"Steve" wrote in message
news:OIZ4BJn3FHA.696@TK2MSFTNGP09.phx.gbl...
>I am trying to get the ID of a newly inserted record. After initial Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314 Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
>insert,
> the rows can have the same values(Except the PK) so I can't be assured
> that
> I'm getting the most recent record, in fact 100% I'm not.
>
> Is there a way that I can SELECT a single record from a table and only
> return the row that has the highest value for a given column?
>
> Thanks for any help,
> Steve
>
> | 
01-Nov-2005, 13:40 PM
|  | Guest | | | | | | | | | | RE: get most recent inserted record You need to add a DateTime field to your table with a default =Now() so the
when the record is created it will have the date and time.
"Steve" wrote:
> I am trying to get the ID of a newly inserted record. After initial insert, Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
> the rows can have the same values(Except the PK) so I can't be assured that
> I'm getting the most recent record, in fact 100% I'm not. Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
>
> Is there a way that I can SELECT a single record from a table and only
> return the row that has the highest value for a given column?
>
> Thanks for any help,
> Steve
>
>
> | 
02-Nov-2005, 11:47 AM
|  | Guest | | | | | | | | | | Re: get most recent inserted record
Steve wrote:
> I am trying to get the ID of a newly inserted record. After initial insert,
> the rows can have the same values(Except the PK) so I can't be assured that
> I'm getting the most recent record, in fact 100% I'm not.
>
> Is there a way that I can SELECT a single record from a table and only Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314 Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
> return the row that has the highest value for a given column?
Yes...e.g. if your table is named MyTable and the 'given column' is
MyID use:
SELECT MyTable.*
FROM MyTable INNER JOIN (SELECT Max(MyTable.MyID) AS MaxOfMyID
FROM MyTable)
AS MaxMyTable ON MyTable.MyID = MaxOrders.MaxOfMyID;
HTH,
Bruce | 
02-Nov-2005, 11:47 AM
|  | Guest | | | | | | | | | | Re: get most recent inserted record Well, perhaps I spoke too soon...this answers your question but the
answer to your question may not solve your initial problem, i.e., 'how Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
do I get the ID of a newly inserted record'. If this is a database to
which you have exclusive access and each successive PK is larger than Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
the previous one this SQL will return the last inserted record. If you
are in a multi-user situation it may well return the last inserted
record, but this record may be a record that someone else inserted, not
_your_ last inserted record. If you are trying to retrieve the ID of
the last record that you inserted you will need to insert the record
using VBA with an ADO or DAO recordset in order to accurately retrieve
that ID.
Bruce | 
02-Nov-2005, 11:47 AM
|  | Guest | | | | | | | | | | Re: get most recent inserted record "Steve" wrote in message
news:OIZ4BJn3FHA.696@TK2MSFTNGP09.phx.gbl...
> I am trying to get the ID of a newly inserted record. After initial
insert,
> the rows can have the same values(Except the PK) so I can't be assured Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
that
> I'm getting the most recent record, in fact 100% I'm not.
>
> Is there a way that I can SELECT a single record from a table and only
> return the row that has the highest value for a given column?
>
> Thanks for any help,
> Steve Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
SELECT TOP 1 Field1_Name[, Field2_Name, Fieldx_Name...] FROM Table_Name
ORDER BY PK_Field_Name DESC | 
03-Nov-2005, 11:35 AM
|  | Guest | | | | | | | | | | Re: get most recent inserted record Thanks guys!
Bruce, I am the sole user at this time. In the event that we add more
users, I will move the app over to SqlServer and asp.net as the users will
be out in the field.
Thanks for your answers, everything is up and running now
"Steve" wrote in message
news:OIZ4BJn3FHA.696@TK2MSFTNGP09.phx.gbl...
> I am trying to get the ID of a newly inserted record. After initial
insert,
> the rows can have the same values(Except the PK) so I can't be assured
that
> I'm getting the most recent record, in fact 100% I'm not. Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314 Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6314
>
> Is there a way that I can SELECT a single record from a table and only
> return the row that has the highest value for a given column?
>
> Thanks for any help,
> Steve
>
> | 
Support Us! Become a Promoter! | | Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh! | (View-All)
Members who have read this thread : 0
| | There are no names to display. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Tools | Search | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | » Gurbani Jukebox | Listen to Gurbani while surfing SPN! | » Active Discussions | | | | | | | ਨਾਮਾ Today 06:37 AM 2 Replies, 53 Views | | | | | | | | | | | | | | | | | | | | | | | » Books You Should Read... | | | |