Library tutorials & articles

Identifying Your New Records

Introduction

While the use of AutoNumber and Identity fields in tables is greatly applauded by database designers the world over, they can be annoying for developers to use. The problem being that, when we add records to the database, there are many cases where we need to know the key of the record that has just been added. Fortunately, there are a number of techniques that are available to assist us in our task. In this article we look at the methods for both SQL Server and Access, with an eye to the pros and cons of each. As always, our goal is to give you enough information to make up your mind.

Comments

  1. 18 Mar 2007 at 20:18
    Hi; perhaps you can offer a little advice.

    I'm writing a small application and am having some positioning challenges with a continuous form which inserts new entries into the record set using a combo box.

    I have a Microsoft buggie feature in this mode, where each new entry - as I move to the next record - reverts to identical form content to the previous line.  Let's say the last entry in the form was for "Orange Juice".  Basically, if I select "Grapefruite Juice" as the next entry, then tab on down to the next line and enter "Cranberry", I end up with the last three lines on the form reading "Orange Juice".  The record IS accurate - when I requery, the data is there.  However, this makes data entry clunky and unprofessional.  Can't seem to fix the form.

    My fix has been to add a little code that requeries.  Naturally, the issue then is that the form resorts and the cursor / bookmark returns to the default first entry in the form.  That makes data entry slow and jerky, plus you lose sight of the last lines entered for reference.

    Be nice if the form read out correctly line after line - OR, I could find a way to requery, then drop the cursor on the last record entered.  Then the user could see pretty graphically, and logically, where their new entry fell in the sort order.

    Any ideas?

    Aaron













  2. 01 Jan 1999 at 00:00

    This thread is for discussions of Identifying Your New Records.

Leave a comment

Sign in or Join us (it's free).

Bruce Johnson I am the owner of a small application development consulting company that specialized in the design and implementation of Internet-based applications. While there are others who can make a web sit...
AddThis

Related podcasts

Events coming up

  • Jul 7

    Midlands PASS Chapter July Meeting

    Columbia, United States

    Midlands PASS welcomes SQL Server MVP John Welch. John will be giving a talk on Getting Started with Analysis Services 2008. We meet in the Training Concepts facility (Suite 502).

We'd love to hear what you think! Submit ideas or give us feedback