Solved

Counter in Datareport

Posted on 2001-08-26
12
309 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

832 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