[ obradorriuss @ 10.08.2004. 15:09 ] @
Kako da mi polje tipa autonumber pocinje od 100 npr? Mozete li mi pomoci i oko coda u VB6 koji omogucava da ukoliko imam zapise 1,2,3,4,5 i obrisem zapis br. 5, sledeci zapis bude 5 a ne 6 kao sto autonumber dodeli???? hvala
[ istok @ 11.08.2004. 21:55 ] @
Ovo sam nasao skoro... Ti bre covece kao da radis moju aplikaciju, ha, ha...
Evo ti ovo pa se snalazi.

Function setRecordID(strObject As String, strField As String)
Dim myWS As DAO.Workspace
Dim mydb As DAO.Database
Dim myRS As DAO.Recordset
On Error GoTo err_setRecordID

Set myWS = DBEngine(0)
Set mydb = CurrentDb
Set myRS = mydb.OpenRecordset(strObject, dbOpenDynaset)

myWS.BeginTrans
' Do bulk changes to Recordset.
With myRS
.MoveFirst
Do While Not .EOF
.Edit
.Fields(strField) = .AbsolutePosition + 1
.Update
.MoveNext
Loop
End With
' If all updates done successfully, commit the transaction.
myWS.CommitTrans
Exit Function

err_setRecordID:
Select Case Err.Number
Case 3078
'invalid Object name
MsgBox "invalid Object name."
Case Else
'If any error occur while making the updates
'all of the changes will be rolled back (not saved).
MsgBox "Start the function again, updating problems."
myWS.Rollback
End Select

Exit Function

End Function

Guys, I tried it out and it works so fine.
Notes:
1) strObject could be a local, linked table, query, or an SQL statement.
2) StrField is the name of the field you want to autonumbered
3) If you use Access 97, please remove “DAO.” From the beginning of the function
Syntax:
Here’s some examples of using the function…
setRecordID( “Table1”, “Field1”)
setRecordID(“Query1”, “Field1”)
setRecordID(“SELECT * FROM table1”, “Field1”)

Disadvantage:
I encountered one disadvantage that you have to run this function after every time you add or delete records from your table.
[ obradorriuss @ 12.08.2004. 21:01 ] @
Ljudi problem je resen pomocu Append querija!!!!!