473,624 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Transact ionID) Then
TransactionID = DMax("tblNewNum ber", "TransactionID" )+1
Else
TransactionID = DMax("tblTransa ctionsNew", "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 2128
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*****@megavi sion.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(Transact ionID) Then
TransactionID = DMax("tblNewNum ber", "TransactionID" )+1
Else
TransactionID = DMax("tblTransa ctionsNew", "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*****@megavi sion.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("tblTransa ctionsNew", "TransactionID" )+1 . . will not
execute if table is empty
If transactionID = 0 then . . . . table was empty
TransactionID = DMax("tblTransa ctionsOld", "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
1346
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 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...
13
7399
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 created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
3
4560
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 set textboxes, radio buttons, etc - that viewstate is fine. Then I have a linkbutton that does a Server.Transfer over to Page2.aspx. When I Server.Transfer back to Page1.aspx, the viewstate info is lost. I ran across another example of this last...
7
3964
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 you wanted to show a list of all of these how would you iterate through this and re populate the object variables? Are there any tutorials that you can recommend on this subject?
6
8836
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 when DST is in effect. This has been working fine for years, but I am worried about the upcoming change in 2007 in the US, which will be followed by a number of Canadian provices (where my application is used). The function that I use is very...
5
7340
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 at the moment for queries but for datasheet forms I find that it automatically saves column positions and widths without prompting to save changes. I should mention i am using Access 2000
5
1410
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 box with Formulas for Chemicals our company makes. I'd like to be able to have only the next formula in line of the schedule to be the only one to be selected but the others grayed out. Once the next selection is made in this combo box it will...
3
1729
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 button and saving it from another table?
1
5003
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 a button, and a dialog box appears. The user enters a name into the dialog box to identify the list for later use, presses OK and the list is saved. In the code, I'm using DoCmd.RunSql on the data in the table, so all the data in the sub form...
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.