Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Pomoc da polje autonumber pocinje npr. od 100?

[es] :: Access :: Pomoc da polje autonumber pocinje npr. od 100?

[ Pregleda: 3774 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

obradorriuss
Nikola Obradovic
CEO & Founder
NO SOLUTIONS
Novi Sad

Član broj: 30270
Poruke: 177
*.ptt.yu.

ICQ: 329831125
Sajt: www.nosolutions.rs


Profil

icon Pomoc da polje autonumber pocinje npr. od 100?10.08.2004. u 15:09 - pre 239 meseci
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
 
Odgovor na temu

istok
Nikola Raonic

Član broj: 16032
Poruke: 13
*.193.EUnet.yu



Profil

icon Re: Pomoc da polje autonumber pocinje npr. od 100?11.08.2004. u 21:55 - pre 239 meseci
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.
 
Odgovor na temu

obradorriuss
Nikola Obradovic
CEO & Founder
NO SOLUTIONS
Novi Sad

Član broj: 30270
Poruke: 177
*.ptt.yu

ICQ: 329831125
Sajt: www.nosolutions.rs


Profil

icon Re: Pomoc da polje autonumber pocinje npr. od 100?12.08.2004. u 21:01 - pre 239 meseci
Ljudi problem je resen pomocu Append querija!!!!!
 
Odgovor na temu

[es] :: Access :: Pomoc da polje autonumber pocinje npr. od 100?

[ Pregleda: 3774 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.