Rabu, 30 Desember 2015

Re: [MS_AccessPros] Primary Key Field to re-start numbering from 1

 

James-


Also found this comment online about using Counter:

You may also need to make sure that your database is set up to use ANSI 92 so that COUNTER is recognized as a legitimate data type.

In Access 2007 go to Access Options, Object Designers, SQL Server compatability syntax (ANSI 92) to set this.



John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Dec 30, 2015, at 4:14 PM, John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

James-

Hmmm.  That used to work back in about 2003.  Try Identity instead of Counter.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Dec 30, 2015, at 4:01 PM, James Asante asanteza@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Getting "Invalid field data type"

Regards,
James

On Wed, Dec 30, 2015 at 4:50 PM, John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 

James-


That's a query, not VBA code.  You could do it like this:

    CurrentDb.Execute "ALTER TABLE MyTable ALTER COLUMN ID Counter(1, 1);", dbFailOnError

Substitute your table name for "MyTable".

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Dec 30, 2015, at 3:35 PM, James Asante asanteza@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Hi John,
Getting "Compile error: Expected: end of statement"

Regards,
James

On Wed, Dec 30, 2015 at 3:02 PM, John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 

James-


Run a query like this:

ALTER TABLE MyTable ALTER COLUMN ID Counter(1, 1);

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Dec 30, 2015, at 12:56 PM, James Asante asanteza@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Hi
I have a table that is deleted and appended from time to time. The primary key has the following properties:

Field Name = ID
Data Type = AutoNumber
Field Size = Long Integer
New Values = Increment
Indexed = Yes (No Duplicates)
Text Align = General

Is there a way to get the ID to start at 1 when the table is cleared (deleted) and appended every time?

Thanks
James










__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

.

__,_._,___

Tidak ada komentar:

Posting Komentar