473,411 Members | 2,080 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,411 software developers and data experts.

Assigning Sequential Numbering

I am using Access 2003. I need to create a
database to transfer accounts receivable data from one system (A) to another system (B) via text files for a friend's business.

I have created a database (entitled AR) that has several tables created and updated from append queries. I have it set to update all the tables by using macros to delete and append the tables with updated information, and then set to export the tables to text files with the exact layout required by System B. Everything with the database works fine, except for one aspect.

In the "Payment table" which lists all payments for all invoices, I am required (by system B) to assign sequential numbering for each invoice payment. For example, if there was 5 partial payments for invoice #123, I would have to assign "1" to the first payment, 2 to the second payment, etc into a column entitled "PaymentNum." Then for invoice #124 which has 2
payments, I would have to assign 1 to the first payment, 2 to the second payment in the same "PaymentNum" column. My queries are already set to sort the table by invoice numbers in ascending order so that the sequential numbers
can be assigned.

I assume I can write a function in Visual Basic in order to include it in my append query, but I am unsure whether this can even be done, or how to execute the code to assign these numbers. I have tried a couple of books but they don't seem to have any specifics on this exact procedure.
Any advice or guidance would be greatly appreciated.
Jun 3 '10 #1
3 2291
gershwyn
122 100+
You can do this using the DCount function in an update query, assuming that you have a way to easily differentiate between records. For example, if your table has an autonumber field called "RecordID", this SQL will update the payment numbers:

Expand|Select|Wrap|Line Numbers
  1. UPDATE PaymentTable SET PaymentNum = DCount(1, "PaymentTable", "InvoiceNum = " & [InvoiceNum] & " AND RecordID <= " & [RecordID]);
That is counting how many records exist that a) have the same invoice number as the current record and b) have a recordID that is less than or equal to the current record, and using that as the payment number.
Jun 3 '10 #2
patjones
931 Expert 512MB
How are you discerning what the "first", "second", "third", etc. payments are? By using payment dates, or maybe some kind of record number as gershwyn suggested? This would clarify things a bit.

Pat
Jun 3 '10 #3
NeoPa
32,556 Expert Mod 16PB
Some information as to the data you're working with would certainly be necessary before providing a matching solution, but certainly the concept illustrated in Gershwyn's post is fundamentally a good one.
Jun 3 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: cjm | last post by:
I need to group records and assign a setid to the group. I have a table with data that looks like this ColA ColB 94015 01065 94016 01065 94015 01085 94015 01086 33383 00912 32601 00912
5
by: Charles McCaffery | last post by:
I have written a database with auto-numbering and now wish to remove alkl of my test data and set the auto-numbering back to one. How do I do this please? Charles McCaffery.
0
by: Lynn | last post by:
I have a query which shows start date and the last 4 digits of a person's SSN. I need sequential numbering of an assending start date yet desending last 4 digits of SSN (L4SSN). Using: RowNum:...
4
by: cliff williams | last post by:
how can I set a form so that when i open it , it appears with the next sequential number. I want to set the number pattern and not use autonumber
2
by: Anderson | last post by:
I have a table which has employee number. I have attempted to creat a function whic will derive a unique number for each record how ever the code below only returns 10,000 for all records. What I...
1
by: S. van Beek | last post by:
Dear reader, Is there a function to use in a query for numbering the records starting with one (1) and then second (2) and so on? Thanks for any help
0
by: Philip Poole | last post by:
Hello everyone, At the moment I am coding a program to create a report, the report is broken down into different componenets such as page etc, each of the compenents can have metadata such as...
2
by: John | last post by:
Hi I need to assign sequential invoice numbers to orders starting from the last highest number + 1. I have tried the following code; UPDATE Orders SET Orders. = DMax("","Orders")+1 WHERE...
0
by: palmorek | last post by:
I am trying to build a macro in Excel for the purpose of authorizing checks. I am trying to figure out when the user is done entering their information they hit an enter button and the macro will...
1
by: wbw | last post by:
I have a database of products in which I have determined when the product sold. The table has two fields ITEM and SOLD. Each product’s first selling date may be different and may not have sold in...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.