VBA function to create a sequence number
Posted on 2004-04-07
hi, i am a beginner, so i think this would be easy for you guys.
I have this function in my module to create a sequence number. I called this function in my update query. I hope that this function will retirn a sequence but instead in retuns the same number for every record. This is my function.
Public currNo As Integer
Function addNo() As Integer
currNo = currNo + 1
addNo = currNo
* The reason I use currNo as public variable is to make sure that it will keep in the memory what is the current value. Maybe my method is wrong.
One more thing, I put this function in the query design, I assume that it will run this function row by row. Am I wrong about this?
this is my sql statement
UPDATE ACCOUNT_ACTIVITY SET ACCOUNT_ACTIVITY.ACC_SEQ = addNo()
WHERE (((ACCOUNT_ACTIVITY.ACC_ID)="1") AND ((ACCOUNT_ACTIVITY.ACC_DESC)="CLEARING CHQ"));
Really need help on this.