Latest topics
Poll
Statistics
We have 12 registered users
The newest registered user is reagkla

Our users have posted a total of 41 messages in 35 subjects
Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

[ View the whole list ]


Most users ever online was 108 on Mon Sep 01, 2008 4:48 pm
Welcome To Random Forum Topics

Wed Aug 27, 2008 7:00 pm by Dan

Please refrain from posting illegal or commonly offensive material.

Comments: 1

RSS feeds


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 


Affiliates
free forum
 


TV
Watch TV Online

MS-Access. Create a new autonumber field in existing table.

View previous topic View next topic Go down

MS-Access. Create a new autonumber field in existing table.

Post  Dan on Sun Aug 24, 2008 1:40 pm

Sub CreateNewAutonumberfield()

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim idx As DAO.Index
Dim rel As DAO.Relation


Set db = CurrentDb
On Error Resume Next
'********************************************

' Create new field ID2 of table Table1
Set tdf = db.TableDefs("T_AdjustCntlRecord")
Set fld = tdf.CreateField("ID2", dbLong)
SetPro fld, "Attributes", dbLong, 17
tdf.Fields.Append fld
SetPro fld, "AllowZeroLength", dbBoolean, False
SetPro fld, "DefaultValue", dbText, ""
SetPro fld, "OrdinalPosition", dbLong, 1
SetPro fld, "Required", dbBoolean, False

' create index ID2 of table Table1
Set tdf = db.TableDefs("T_AdjustCntlRecord")
Set idx = tdf.CreateIndex("ID2")
Set fld = idx.CreateField("ID2")
idx.Fields.Append fld
tdf.Indexes.Append idx


End Sub



Private Sub SetPro(o As Object, s As String, t As DataTypeEnum, v As Variant)
'Set the properties
On Error GoTo Problems
o.Properties(s) = v
Exit Sub
Problems:
If Err = 3270 Then
o.Properties.Append o.CreateProperty(s, t, v)
Resume ProblemsX
End If
On Error GoTo 0
Resume
ProblemsX:
End Sub

Dan
Founder
Founder

Number of posts : 30
Registration date : 2008-08-23

View user profile http://generalforum.usersboard.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum