Hello all,
I have a report which is connected to a query that collects data based on some filters. Now, my question is, how do I make an autonumber starting from 1 get generated everytime there is a page break for a dummy text field on the report? This field is not part of any table but just a serial number. Example below.
Page 1 of report.
ID Description Qty Price
=======================
1 x x x x x x x x x x x
2 x x x x x x x x x x x x x
3
...
Page 2 of report
ID Description Qty Price
=======================
1 x x x x x x x x x x x
As you can see the value ID does not belong to any table. Just a number which starts at 1 and displays record count.
Please help. :)
Thanks!
4 3612
Hello all,
I have a report which is connected to a query that collects data based on some filters. Now, my question is, how do I make an autonumber starting from 1 get generated everytime there is a page break for a dummy text field on the report? This field is not part of any table but just a serial number. Example below.
Page 1 of report.
ID Description Qty Price
=======================
1 x x x x x x x x x x x
2 x x x x x x x x x x x x x
3
...
Page 2 of report
ID Description Qty Price
=======================
1 x x x x x x x x x x x
As you can see the value ID does not belong to any table. Just a number which starts at 1 and displays record count.
Please help. :)
Thanks!
Hi, irkahs.
Here is one possible solution. - Place the following function in code module
-
Public Function AutoNumber(ByVal varDummy As Variant, _
-
Optional ByVal lngSeed As Variant) As Long
-
-
Static lngAutoNumber As Long
-
If Not IsMissing(lngSeed) Then
-
lngAutoNumber = lngSeed
-
Else
-
AutoNumber = lngAutoNumber
-
lngAutoNumber = lngAutoNumber + 1
-
End If
-
-
End Function
-
- Create a query based on your table (lets say tblYourTable)
-
SELECT tblYourTable.*, AutoNumber(tblYourTable.[Any table field]) AS AutoNum FROM tblYourTable;
[Any table field] means any table field no matter what, just to force AutoNumber function to run for each record
- Create a report based on the query
- In report in page header format event place the following code resetting autonumber to 1
-
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
-
AutoNumber 0, 1
-
End Sub
-
Good luck.
Hello all,
I have a report which is connected to a query that collects data based on some filters. Now, my question is, how do I make an autonumber starting from 1 get generated everytime there is a page break for a dummy text field on the report? This field is not part of any table but just a serial number. Example below.
Page 1 of report.
ID Description Qty Price
=======================
1 x x x x x x x x x x x
2 x x x x x x x x x x x x x
3
...
Page 2 of report
ID Description Qty Price
=======================
1 x x x x x x x x x x x
As you can see the value ID does not belong to any table. Just a number which starts at 1 and displays record count.
Please help. :)
Thanks!
- Create an Unbound Text Box on you Report and Name it ID.
- In the General Declarations Section of your Report Module, enter the following line of code:
- Dim intCounter As Integer
- In the Print() Event of your Report's Detail Section, place the following code:
- Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
-
intCounter = intCounter + 1
-
Me![ID] = intCounter
-
End Sub
- In the Print() Event of your Report's Page Footer Section, place the following code:
- Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
-
intCounter = 0
-
End Sub
- I do believe that this is as compact as you are going to get as far as coding is concerned - it only takes 4 lines of code to do the trick, and it is independent of the Record Source.
Thank you guys for the much appreciated response! It works just fine. I used the second method suggested by ADezii and it works like a charm. :)
Thank you once again.
Cheers!
Thank you guys for the much appreciated response! It works just fine. I used the second method suggested by ADezii and it works like a charm. :)
Thank you once again.
Cheers!
You are quite welcome - always glad to help!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: SharkSYA |
last post by:
After canvassing ideas it appears that the way I need to do it is not
possible.There are 126 rooms, more to be added, and it needs to print a
report or reports showing 76 days of bookings.
There...
|
by: CSDunn |
last post by:
Hello,
I have a situation with MS Access 2000 in which I need to display report
data in spreadsheet orientation (much like a datasheet view for a form). If
you think of the report in terms of what...
|
by: Terri |
last post by:
I have a form with a multi-select combo. I dynamically build a SELECT
statement, open a report, and set the recordsource to my dynamic SELECT
statement. I count the records returned in the report...
|
by: Nathan Bloomfield |
last post by:
Does anyone know if there is any documentation which relates to Access2k + ?
or can anyone help adjust the code?
I am having trouble converting the DAO references.
TITLE :INF: How to...
|
by: CSDunn |
last post by:
Hello,
I have a format issue on an Access 2000 ADP report that I am going to
attempt to explain from a 'ten thousand foot view' :
I have an Access 2000 ADP report that has a SQL Server 2000...
|
by: Andy_HR |
last post by:
1. question
when i have custom autonumber field... like Nz(DMax("ClanID",
"tblClanovi")+1 how can i make it try again if someone else pressed the save
button and that namber is already taken,..??...
|
by: Brad |
last post by:
Thanks for taking the time to read my question.
I have a table of data that has Date, Data and Category. I need to
show, in
a report, each Categories Data by Date. The Date has to be it's own...
|
by: Alan Mailer |
last post by:
A project I'm working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any...
|
by: creative1 |
last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
|
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: 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...
|
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...
|
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: 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,...
|
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,...
| |