Kamis, 02 Januari 2014

[MS_AccessPros] (unknown)

 

Hi All,

I have a form on which i had a field "TransactionID" as AutoNumber, set as key. I was having problems if a record was deleted from button on form OR Undo from a button and then adding new record it was new TransactionID.
That is if TransactionID = 4 deleted or Undo, for new record i do not get TransactionID = 4, but get TransactionID = 5

I read on a forum the following, but i am not sure where to put this code, and also would it work or not. Could somebody help.

Khalid

Change your field from an autonumber to long integer and use the following code on your add record forms.

Code:
Dim varID As Variant         If IsNothing(YourID) Then          ' Get the previous high number and add 1          VarID = DMax("YourFieldname", "YourTableName") + 1          ' If this is first one, then value will be null           If IsNull(YourID) Then YourID = 1                FieldID = VarID       End If

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar