Hello
I am trying to write a query which will ultimately feed a report that will print out invoices for each of my clients. I currently have a query that pulls each client's name and amount due. I now need to add an invoice number. I want these to be sequential. Is there a way to get each row in the query to increase by 1? I know this is possible within the Report by using the Running Sum property, but I really need this is the query.
Would appreciate any insight!
Thanks :)
6 2783
Can you just add an autonumber field to the table? That would do it for you. Or did I misunderstand?
If this is actually an invoice number, I think you would want it to be permanent, and therefore part of a table. You don't want to print an invoice for your customer, then next time you run the query, get a difference number assigned to the record.
So question becomes: How do I get this autonumber to adjust each month if I have a static table? Currently I manually go through and change the invoice numbers by taking the last invoice number used the prior month and adding 1 to it and then type this sequentially all the way down my client list. Is there an update query I can run that can do this?
I guess I'm not clear on exactly what your requirements are. What good is an invoice number if you are going to just change it?
If you are going to have an invoice number, it would normally refer to an object which is an invoice. Objects are represented by records which are stored in tables. This implies that you have a table of invoices.
@elaspina
I do have a work-around solution that will automate the process of sequentially numbering the Invoices from the Last Entered, but it is a stretch. I'll just wait and see what, if any, solutions are provided to you.
Assuming your Original Table is named tblInvoices and contains a Field uniquely identifying the Invoice Number named [InvoiceID]: - Change your SELECT QUERY to a MAKE TABLE QUERY, but do NOT include the [InvoiceID] Field. Name the newly created Table tblInvoicesNew.
- Add a Field to tblInvoicesNew named [InvoiceID]. This Field must be a LONG INTEGER and NOT AutoNumber, or be a Primary Key.
- Execute the following code:
- Dim MyDB As DAO.Database
-
Dim rstInvoice As DAO.Recordset
-
Dim lngLastInvoiceID As Long
-
Dim lngCounter As Long
-
-
lngCounter = 0 'Initialize
-
-
Set MyDB = CurrentDb
-
Set rstInvoice = MyDB.OpenRecordset("tblInvoicesNew", dbOpenDynaset)
-
-
'Assuming your Original Table is named tblInvoices and contains a
-
'Field named [InvoiceID], and contains Records (simplified Version)
-
lngLastInvoiceID = DMax("[InvoiceID]", "tblInvoices")
-
-
With rstInvoice
-
Do While Not .EOF
-
lngCounter = lngCounter + 1
-
.Edit
-
![InvoiceID] = lngLastInvoiceID + lngCounter
-
.Update
-
.MoveNext
-
Loop
-
End With
-
-
rstInvoice.Close
-
Set rstInvoice = Nothing
- tblInvoicesNew will now consist of Sequentially Number Invoice IDs starting from 1+ the Last [InvoiceID] in tblInvoices.
- Make tblInvoicesNew the Record Source for your Report, and you should be in business.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tanamon |
last post by:
Hello All,
I am a MySQL newbie trying to write a query that selects file_name records
possessing the highest numbered version for that unique file_name. I show
sample data and two trial queries...
|
by: J Smith |
last post by:
I'm making a website where each page has the same design, obviously its
a bad idea to put the same code/html in each page so what is the best
way to do this?
What I'm doing at the moment is...
|
by: Mike Conklin |
last post by:
This one really has me going. Probably something silly. I'm using
dcount for a report to determine the number of different types of
tests proctored in a semester.
My report is based on a...
|
by: Chasing Gates |
last post by:
I have created a database that brings in a new table weekly. I then
made a separate query for each sales rep and a separate report for each
rep. (The reports are all identical but call different...
|
by: manning_news |
last post by:
Using A2K. I've been asked to modify a report currently requiring only
one date parameter to now accept a date range. The main report has 2
subreports and is not bound to a table or query. The...
|
by: geronimo_me |
last post by:
I have 20 queries that compare fields in one table with fields in
another table - the query results are the records that do not match in
Table1 and Table2. ie
Table1
DOB 28/02/78
Table2
DOB...
|
by: tHeRoBeRtMiTcHeLL |
last post by:
Below is an earlier post to an Excel Group..
....but I thought that there might be a way to do this in Access
by importing data and then creating append and/or update query. I would
most certainly...
|
by: Kevin.S.Campbell |
last post by:
Greetings,
I'm trying to run a sql query on a continous form. I have the
query working correctly the way I want it. I want this query to be
displayed on the form in the text box on the load...
|
by: MLH |
last post by:
I have a source query (qryITSLetterList) feeding rows containing name,
addr, city, state, zip and VehicleID to a report (rptITSnotices). The
query may contain 1-to-5 records resulting in 1-to-5...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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: 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,...
| |