Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2004, 10:49 AM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dcary69 Send a message via Yahoo to dcary69
Default setting seed for autonumber in access

Hi,

Is it possible to set the autonumber seed in access like SQL server?

Cheers,:D

Dan Cary
 
Old October 5th, 2004, 12:37 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dcary69 Send a message via Yahoo to dcary69
Default

Ok I found my solution:

Microsoft Knowledge Base Article - 287756

Function below resets seed. You need to add two references for this function to work.

Microsoft ActiveX Data Objects 2.x and the Microsoft ADO Ext 2.x for DDL and Security Libraries

......or higher

Function ChangeSeed(strTbl As String, strCol As String, lngSeed As Long) As Boolean
'You must pass the following variables to this function.
'strTbl = Table containing autonumber field
'strCol = Name of the autonumber field
'lngSeed = Long integer value you want to use for next AutoNumber.

Dim cnn As ADODB.Connection
Dim cat As New ADOX.Catalog
Dim col As ADOX.Column

'Set connection and catalog to current database.
Set cnn = CurrentProject.Connection
cat.ActiveConnection = cnn

Set col = cat.Tables(strTbl).Columns(strCol)

col.Properties("Seed") = lngSeed
cat.Tables(strTbl).Columns.Refresh
If col.Properties("seed") = lngSeed Then
    ChangeSeed = True
Else
    ChangeSeed = False
End If
Set col = Nothing
Set cat = Nothing
Set cnn = Nothing

End Function

Cheers,

Dan Cary





Similar Threads
Thread Thread Starter Forum Replies Last Post
Autonumber in Microsoft Access ozzii Classic ASP Databases 1 January 17th, 2007 04:08 PM
autonumber problem in Access Pat Crotty Access VBA 2 September 6th, 2006 10:37 AM
Access Autonumber chall90909 Access ASP 1 November 21st, 2004 10:26 AM
ASP and Access AutoNumber phungleon Access ASP 2 October 10th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.