473,408 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Saving last TransactionID to another table

PMB
Thank you in advance for any and all assistance.

I'm trying to keep my numbers for transactions sequential. I clear my
monthly transactions each month and store them in a general transactions
table. My problem is, everytime I clear the table, it wants to start back at
Zero, which conflicts with records that are already created.

Is there a way to create a second table and store the value of the last
transaction and pull it into the transactions for the new month?

I've tried psuedo code of; (neither field is AutoNumber)

If IsNull(TransactionID) Then
TransactionID = DMax("tblNewNumber", "TransactionID")+1
Else
TransactionID = DMax("tblTransactionsNew", "TransactionID")+1
End If

But, it doesn't work all the time. HELP

Also, how can I save the last transaction into the new table so that the
transactionID's are sequential?
Michael

Nov 12 '05 #1
2 2118
When you Compact, it reinitializes AutoNumber to one more than the highest
value in the AutoNumber field (if you are using numeric, not GUID) -- thus,
if your clear the table, the highest used AutoNumber in that table is 0, so
it reinitializes to 1.

When you use DMax, it returns the highest number you have used in that
field -- thus, if all your records are gone, it returns 0, so you will start
with 1.

If you don't want that behavior, then you'll have to use a different
approach... perhaps have your own TableInfo table with table names and
highest-used-ident... don't clear that along with the transaction table, and
it should pick up where you left off. On the other hand, you could simply
leave it the way you have it and use Month/Year to form a multi-field key
with the AutoNumber.

Larry Linson
Microsoft Access MVP
"PMB" <pm*****@megavision.com> wrote in message
news:GN*****************@news.uswest.net...
Thank you in advance for any and all assistance.

I'm trying to keep my numbers for transactions sequential. I clear my
monthly transactions each month and store them in a general transactions
table. My problem is, everytime I clear the table, it wants to start back at Zero, which conflicts with records that are already created.

Is there a way to create a second table and store the value of the last
transaction and pull it into the transactions for the new month?

I've tried psuedo code of; (neither field is AutoNumber)

If IsNull(TransactionID) Then
TransactionID = DMax("tblNewNumber", "TransactionID")+1
Else
TransactionID = DMax("tblTransactionsNew", "TransactionID")+1
End If

But, it doesn't work all the time. HELP

Also, how can I save the last transaction into the new table so that the
transactionID's are sequential?
Michael

Nov 12 '05 #2
hi
you could look for the dmax record in the trransaction file . . if it is >
0 then add 1 and use that number . .
if it is zero ( ie doesnt exist ) then get the highest number from the
history table and add 1.

see below

"PMB" <pm*****@megavision.com> wrote in message
news:GN*****************@news.uswest.net...
Thank you in advance for any and all assistance.

I'm trying to keep my numbers for transactions sequential. I clear my
monthly transactions each month and store them in a general transactions
table. My problem is, everytime I clear the table, it wants to start back at Zero, which conflicts with records that are already created.

Is there a way to create a second table and store the value of the last
transaction and pull it into the transactions for the new month?

I've tried psuedo code of; (neither field is AutoNumber) * * * * * *
on error resume next . . . will ignore the error when no transaction records
exist
transactionID = 0
TransactionID = DMax("tblTransactionsNew", "TransactionID")+1 . . will not
execute if table is empty
If transactionID = 0 then . . . . table was empty
TransactionID = DMax("tblTransactionsOld", "TransactionID")+1
else
TransactionID = TransactionID + 1
endif
cheers
paul


But, it doesn't work all the time. HELP

Also, how can I save the last transaction into the new table so that the
transactionID's are sequential?
Michael

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to keep my numbers for transactions sequential. I clear my monthly transactions each month and store them in a general transactions...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
7
by: Gav | last post by:
If you had a class user with variables id, name, password. How would you save this object or its variable date to a MySQL database? And then if you had a dbase populated with id, name, password and...
6
by: Robm | last post by:
Since googling this issue only brings up the April fool's problem, which was solved years ago, I hope that somebody can help me with this. I have a large vc++/mfc application which needs to know...
5
by: deekay | last post by:
I want to allow users to resize and reposition columns of a datasheet but for a prompt to be brought up and only the layout only to be saved if they select "save changes". This is the way it works...
5
by: wideasleep | last post by:
Hi Everyone, I have a design issue here (go figure) on a form and kind of need some opinions on how to do this. I have my ideas but need a 2nd, 3rd, 4th.......opinions. 1st I will have a combo...
3
by: bluethunder | last post by:
Good morning guys, I have a problem regarding the usage of the command button in VB 6. I dont know what codes what i will gonna use. How will i gonna call the records from the table using command...
1
by: AdamOnAccess | last post by:
I'm in Access 2007. I built a feature that to saves the current list in a sub form to a separate table. It works like this: After entering a list of words in the subform, the user can choose to push...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.