Solved

Counter in Datareport

Posted on 2001-08-26
12
311 Views
Last Modified: 2008-10-16
How to make a counter in the Datareport, so counter will be displayed as an order number in the report. I also need the counter can be reset everytime the header changes.
0
Comment
Question by:falconew
  • 5
  • 4
  • 3
12 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6428273
An Identity field (or AutoNumber in Access) can help you.
0
 
LVL 1

Author Comment

by:falconew
ID: 6430423
Thanks for your response. The problem is my database does not have the identity field. And I just want to display the ordered number for details and everytimes the header changes the number would be reset.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6430431
Create a new dummy table that will give you invoice number.

If you print invoice number, you should keep them somewhere in your database so that if your customer reference it, you can have a way to find it!
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:raybeam
ID: 6431222
use a count RptFunction Control in data report in the Header Footer
0
 
LVL 1

Author Comment

by:falconew
ID: 6435062
The number has nothing to do with the database. I just need the number will displayed in the report details as the ordered number to indicate which line it is. For example:

Customer ID: 1001   --> (this the header)
=================
No.         Order ID       Product ID  
=====================================
 1.          A001          bla bla      -> (this the detail)
 2.          B323          vla bla
 .
 .
 etc.

so I just need the field "No." to be count up until the end of details. And it need to be reset if the customer ID has changed. The field No. is not in the database.

Any help or suggestion would be greatly appreciated.
0
 
LVL 1

Expert Comment

by:raybeam
ID: 6436002
put a temp field in the orders table and run a procedure to fill it before you open the datareport...it's an easy trick...
0
 
LVL 1

Author Comment

by:falconew
ID: 6443288
I don't think it is easy and efficient to do that, because we need a logic programming for numbering the details.
0
 
LVL 1

Expert Comment

by:raybeam
ID: 6443701
The procedure is as follow:

1-Execute the same query you'r gonna execute to fetch the report data in a VB Module (Use connection object)
Example
{
Dim I AS Integer
I = 0
Set rs = cn.execute("SAME QUERY TO FILL REPORT")
Do While Not rs.EOF
   cn.execute("UPDATE OrderTable SET Rank = " & I " & WHERE Order_ID = " & rs("Order_ID")  
   I = I  + 1
   rs.movenext
Loop
}

Order_ID is the Order Identity field you create as primary key for the orders table
0
 
LVL 1

Expert Comment

by:raybeam
ID: 6444335
also u should use another Recordset right above the order one for customers

SET CustRS = cn.execute("SELECT * FROM CustomerTable WHERE [CRITERIA]")

so the 2nd query should be something like

SET rs = cn.execute("SELECT * FROM OrdersTable WHERE Customer_ID = " & CustRS("Customer_ID"))

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6444394
I just found an article that may interest you: "INF: How to Dynamically Number Rows in a Select Statement" at http://support.microsoft.com/support/kb/articles/q186/1/33.asp
0
 
LVL 1

Expert Comment

by:raybeam
ID: 6446577
hey thanx, that really helped me alot, and it's not even my question :P

:)
0
 
LVL 1

Author Comment

by:falconew
ID: 6447228
Thanks emoreau. It's actually I was looking for.
I also thank for raybeam for the suggestion.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question