Hi all,
Is there a way to create a incremental number in the table of access in a specified field? I have spent most of the day reviewing the post and such but cant seem to find what I am seeking?
May not be possible in the table? I have tried many things but cant get it to perform!
I have a append query that updates a table however it does not have the TransCode in it which is a unique number I get from a function and I need that number.
On form it works like clock work but this event does not open a form, when I click a button it fires the append query and updates a table with mismatched dates.
tblTransactions
TransactionID - AutoNumber
TransactionTypeID - Number
TransCode - Number (Which I want to make an incrementNumber like the TransactionID)
Plus more fields....
I use this on the forms to get the TransCode
But without a form open, I cant seem to get this number into table? I would actually like to just call that function at table level if possible?Code:Code: Option Compare Database Option Explicit 'This will return the last autonumber inserted into the table. It will be unique. 'You can format it into something else for display purposes. Public Function fnHeaderID() As Long Dim sSql As String Dim db As Database sSql = "INSERT INTO tblUniqueIDs (UniqueDate) Values (Now())" Set db = CurrentDb db.Execute sSql, dbSeeChanges fnHeaderID = db.OpenRecordset("SELECT @@IDENTITY")(0) Set db = Nothing End Function
Else, I need to find a way to create it. I tried putting fnHeaderID() in a query but then it changes all of them to the next number in sequence.
Any Ideas would be helpful, I have searched this forum, googled it, and cant find anything except how to change the primary key format and I need the PK besides this code.
Thanks
Dave