Click to See Complete Forum and Search --> : Auto Number
dineshasanka
April 27th, 2001, 06:18 AM
Hi There,
1. Is there any way to check the next number of the AutoNumber format of a Access table.
I want to know this for a table whish have zero records.
2. How to initialise the Access table Auto number to 1 by PROGRMATICALLY.
Dinesh Asanka
Iouri
April 27th, 2001, 06:56 AM
1. Is there any way to check the next number of the AutoNumber format of a Access table.
I want to know this for a table whish have zero records.
YOu can execute SQL
SQL = "select max(AutoNumberField) as X from YourTable"
rs.Open SQL,Conn,adOpenDynamic,adLockOptimistic
The next number will be rs!X
2. How to initialise the Access table Auto number to 1 by PROGRMATICALLY.
'set reference to ADOX
Set col = New ADOX.Column
Set col.ParentCatalog = cat
With col
.Type = adInteger
.Name = "ID"
.Properties("Autoincrement") = True
End With
tbl.Columns.Append col
Iouri Boutchkine
iouri@hotsheet.com
Jalpa Shah
April 30th, 2001, 05:27 AM
hello dinesh,
here is the code for auto numbering e.g.
access table = table1
field datatype
no number
name text
vb recordset=rs
dim m_no as integer
now the syntex as below
rs.open "select *from table1"
if rs.bof=true and rs.eof=true then
m_no=1
else
rs.movelast
m_no=(rs.feilds(0).value) + 1
end if
rs.close
text1.text=m_no
otherwise
u cam also write code like
if rs.recordcount <> 0 then
rs.movelast
m_no=rs.feilds(0).value+1
else
m_no=1
end if
but this other option is only properly work with
adocursure=openkeyset,lock=adooplimestic
if till u've an error mail me. all the best.
Jalpa Shah
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.